Wednesday, 17 January 2024

How much do you know about NumPy library?

 



What is NumPy?

a) A programming language

b) A machine learning library

c) A numerical computing library in Python

d) A deep learning framework


Question 2:

Which of the following is the primary purpose of NumPy?

a) Web development

b) Data manipulation and analysis

c) Game development

d) Network programming


Question 3:

What does the term "NumPy" stand for?

a) Numerical Python

b) Nonlinear Python

c) Neural Python

d) Numeral Python


Question 4:

Which of the following is the correct way to import NumPy in Python?

a) import np

b) import numpy as np

c) from numpy import *

d) include numpy


Question 5:

What is the core data structure in NumPy for representing arrays?

a) Lists

b) Tuples

c) Arrays

d) Sets


Question 6:

Which NumPy function is used to create an array with a range of values?

a) numpy.linspace()

b) numpy.range()

c) numpy.aranges()

d) numpy.arange()


Question 7:

What is the result of the following NumPy expression: numpy.zeros(5)?

a) An array with five elements, all set to 1

b) An array with five elements, all set to 0

c) An empty array

d) An array with five elements, all set to 5


Question 8:

Which NumPy function is used to find the mean of an array?

a) numpy.mean()

b) numpy.average()

c) numpy.median()

d) numpy.mean_value()


Question 9:

In NumPy, what does the function numpy.random.rand() do?

a) Generates random integers

b) Generates random floats in the half-open interval [0.0, 1.0)

c) Computes the standard deviation of an array

d) Creates an array with a specified shape and all elements initialized to the same value


Question 10:

What does the term "broadcasting" mean in the context of NumPy?

a) Sending data over a network

b) Extending the dimensions of an array

c) Performing element-wise operations on arrays of different shapes and sizes

d) Converting data types in an array


Question 11:

Which NumPy function is used to perform element-wise multiplication of two arrays?

a) numpy.multiply()

b) numpy.dot()

c) numpy.cross()

d) numpy.product()


Question 12:

How can you reshape a NumPy array with dimensions (4, 5) into a new array with dimensions (2, 10)?

a) array.reshape((2, 10))

b) numpy.resize(array, (2, 10))

c) numpy.reshape(array, (2, 10))

d) array.resize((2, 10))


Question 13:

What is the purpose of the NumPy function numpy.linalg.inv()?

a) Computes the determinant of a matrix

b) Finds the eigenvalues of a matrix

c) Computes the inverse of a matrix

d) Calculates the singular value decomposition of a matrix


Question 14:

Which NumPy function is used to concatenate two or more arrays along a specified axis?

a) numpy.append()

b) numpy.concatenate()

c) numpy.concat()

d) numpy.merge()


Question 15:

How can you find the index of the maximum value in a NumPy array?

a) numpy.max_index()

b) numpy.argmax()

c) numpy.index_max()

d) numpy.maximum_index()


Question 16:

What is the purpose of the NumPy function numpy.fft.fft()?

a) Finds the fast file transfer of an array

b) Computes the fast Fourier transform of an array

c) Calculates the flip-flop transform of an array

d) Performs the fuzzy frequency transformation of an array


Question 17:

Which NumPy function is used to calculate the dot product of two arrays?

a) numpy.dot()

b) numpy.multiply()

c) numpy.cross()

d) numpy.product()


Question 18:

In NumPy, what does the function numpy.where() do?

a) Filters elements of an array based on a condition

b) Finds the index of a specified element in an array

c) Transposes the elements of an array

d) Sorts the elements of an array


Question 19:

What is the purpose of the NumPy function numpy.save()?

a) Saves an array to a text file

b) Saves an array to a binary file in NumPy's .npy format

c) Saves an array to a CSV file

d) Saves an array to an Excel file


Question 20:

How can you find the unique elements in a NumPy array?

a) numpy.unique()

b) numpy.distinct()

c) numpy.uniq()

d) numpy.elements()


Question 1: c) A numerical computing library in Python

Question 2: b) Data manipulation and analysis

Question 3: a) Numerical Python

Question 4: b) import numpy as np

Question 5: c) Arrays

Question 6: d) numpy.arange()

Question 7: b) An array with five elements, all set to 0

Question 8: a) numpy.mean()

Question 9: b) Generates random floats in the half-open interval [0.0, 1.0)

Question 10: c) Performing element-wise operations on arrays of different shapes and sizes

Question 11: a) numpy.multiply()

Question 12: a) array.reshape((2, 10))

Question 13: c) Computes the inverse of a matrix

Question 14: b) numpy.concatenate()

Question 15: b) numpy.argmax()

Question 16: b) Computes the fast Fourier transform of an array

Question 17: a) numpy.dot()

Question 18: a) Filters elements of an array based on a condition

Question 19: b) Saves an array to a binary file in NumPy's .npy format

Question 20: a) numpy.unique()





Managing Machine Learning Projects

 


Build your subject-matter expertise

This course is part of the AI Product Management Specialization

When you enroll in this course, you'll also be enrolled in this Specialization.

Learn new concepts from industry experts

Gain a foundational understanding of a subject or tool

Develop job-relevant skills with hands-on projects

Earn a shareable career certificate

Join Free: Managing Machine Learning Projects

There are 5 modules in this course

This second course of the AI Product Management Specialization by Duke University's Pratt School of Engineering focuses on the practical aspects of managing machine learning projects.  The course walks through the keys steps of a ML project from how to identify good opportunities for ML through data collection, model building, deployment, and monitoring and maintenance of production systems.  Participants will learn about the data science process and how to apply the process to organize ML efforts, as well as the key considerations and decisions in designing ML systems.

At the conclusion of this course, you should be able to:

1) Identify opportunities to apply ML to solve problems for users
2) Apply the data science process to organize ML projects
3) Evaluate the key technology decisions to make in ML system design
4) Lead ML projects from ideation through production using best practices

Python, Bash and SQL Essentials for Data Engineering Specialization

 


What you'll learn

Develop data engineering solutions with a minimal and essential subset of the Python language and the Linux environment

Design scripts to connect and query a SQL database using Python

Use a scraping library in Python to read, identify and extract data from websites 

Join Free: Python, Bash and SQL Essentials for Data Engineering Specialization

Specialization - 4 course series

If you are interested in developing the skills needed to be a data engineer, the Python, Bash and SQL Essentials for Data Engineering Specialization is a great place to start. We live in a world that is driven by big data - from what we search online to the route we take to our favorite restaurant, and everything in between. Businesses and organizations use this data to make decisions that impact the ways in which we navigate our lives. How do engineers collect this data? How can this data be organized so that it can be appropriately analyzed? A data engineer is specialized in this initial step of accessing, cleaning and managing big data.

Data engineers today need a solid foundation in a few essential areas: Python, Bash and SQL. In Python, Bash and SQL Essentials for Data Engineering, we provide a nuts and bolts overview of these fundamental skills needed for entering the world of data engineering. Led by three professional data engineers, this Specialization will provide quick and accessible ways to learn data engineering strategies, give you a chance to practice what you’ve learned in integrated lab exercises, and then immediately apply these techniques in your professional or academic life.

Applied Learning Project

Each course includes integrated lab exercises using Visual Studio Code or Jupyter notebooks that give you an opportunity to practice the Python, Bash and SQL skills with real-world applications covered in each course. For each data engineering solution that you explore, you are also encouraged to create a demo video and GitHub repository of code that can be showcased in your digital portfolio for employers. By the end of this Specialization, you will have the foundational skills necessary to begin tackling more complex data engineering solutions.

Spark, Hadoop, and Snowflake for Data Engineering

 


What you'll learn

Create scalable data pipelines (Hadoop, Spark, Snowflake, Databricks) for efficient data handling.

Optimize data engineering with clustering and scaling to boost performance and resource use.

Build ML solutions (PySpark, MLFlow) on Databricks for seamless model development and deployment.

Implement DataOps and DevOps practices for continuous integration and deployment (CI/CD) of data-driven applications, including automating processes.

Join Free: Spark, Hadoop, and Snowflake for Data Engineering

There are 4 modules in this course

e.g. This is primarily aimed at first- and second-year undergraduates interested in engineering or science, along with high school students and professionals with an interest in programmingGain the skills for building efficient and scalable data pipelines. Explore essential data engineering platforms (Hadoop, Spark, and Snowflake) as well as learn how to optimize and manage them. Delve into Databricks, a powerful platform for executing data analytics and machine learning tasks, while honing your Python data science skills with PySpark. Finally, discover the key concepts of MLflow, an open-source platform for managing the end-to-end machine learning lifecycle, and learn how to integrate it with Databricks.

This course is designed for learners who want to pursue or advance their career in data science or data engineering, or for software developers or engineers who want to grow their data management skill set. In addition to the technologies you will learn, you will also gain methodologies to help you hone your project management and workflow skills for data engineering, including applying Kaizen, DevOps, and Data Ops methodologies and best practices.

With quizzes to test your knowledge throughout, this comprehensive course will help guide your learning journey to become a proficient data engineer, ready to tackle the challenges of today's data-driven world.

MLOps | Machine Learning Operations Specialization

 


What you'll learn

Master Python fundamentals, MLOps principles, and data management to build and deploy ML models in production environments.

Utilize Amazon Sagemaker / AWS, Azure, MLflow, and Hugging Face for end-to-end ML solutions, pipeline creation, and API development.

Fine-tune and deploy Large Language Models (LLMs) and containerized models using the ONNX format with Hugging Face.

Design a full MLOps pipeline with MLflow, managing projects, models, and tracking system features.

Join Free: MLOps | Machine Learning Operations Specialization

Specialization - 4 course series

This comprehensive course series is perfect for individuals with programming knowledge such as software developers, data scientists, and researchers. You'll acquire critical MLOps skills, including the use of Python and Rust, utilizing GitHub Copilot to enhance productivity, and leveraging platforms like Amazon SageMaker, Azure ML, and MLflow. You'll also learn how to fine-tune Large Language Models (LLMs) using Hugging Face and understand the deployment of sustainable and efficient binary embedded models in the ONNX format, setting you up for success in the ever-evolving field of MLOps

Through this series, you will begin to learn skills for various career paths:

1. Data Science - Analyze and interpret complex data sets, develop ML models, implement data management, and drive data-driven decision making.

2. Machine Learning Engineering - Design, build, and deploy ML models and systems to solve real-world problems.

3. Cloud ML Solutions Architect - Leverage cloud platforms like AWS and Azure to architect and manage ML solutions in a scalable, cost-effective manner.

4. Artificial Intelligence (AI) Product Management - Bridge the gap between business, engineering, and data science teams to deliver impactful AI/ML products.

Applied Learning Project

Explore and practice your MLOps skills with hands-on practice exercises and Github repositories.

1. Building a Python script to automate data preprocessing and feature extraction for machine learning models.

2. Developing a real-world ML/AI solution using AI pair programming and GitHub Copilot, showcasing your ability to collaborate with AI.

4. Creating web applications and command-line tools for ML model interaction using Gradio, Hugging Face, and the Click framework.

3. Implementing GPU-accelerated ML tasks using Rust for improved performance and efficiency.

4. Training, optimizing, and deploying ML models on Amazon SageMaker and Azure ML for cloud-based MLOps.

5. Designing a full MLOps pipeline with MLflow, managing projects, models, and tracking system features.

6. Fine-tuning and deploying Large Language Models (LLMs) and containerized models using the ONNX format with Hugging Face. Creating interactive demos to effectively showcase your work and advancements.

Machine Learning Foundations for Product Managers

 


Build your subject-matter expertise

This course is part of the AI Product Management Specialization

When you enroll in this course, you'll also be enrolled in this Specialization.

Learn new concepts from industry experts

Gain a foundational understanding of a subject or tool

Develop job-relevant skills with hands-on projects

Earn a shareable career certificate

Join Free: Machine Learning Foundations for Product Managers

There are 6 modules in this course

In this first course of the AI Product Management Specialization offered by Duke University's Pratt School of Engineering, you will build a foundational understanding of what machine learning is, how it works and when and why it is applied.  To successfully manage an AI team or product and work collaboratively with data scientists, software engineers, and customers you need to understand the basics of machine learning technology.  This course provides a non-coding introduction to machine learning, with focus on the process of developing models, ML model evaluation and interpretation, and the intuition behind common ML and deep learning algorithms.  The course will conclude with a hands-on project in which you will have a chance to train and optimize a machine learning model on a simple real-world problem.

At the conclusion of this course, you should be able to:
1) Explain how machine learning works and the types of machine learning
2) Describe the challenges of modeling and strategies to overcome them
3) Identify the primary algorithms used for common ML tasks and their use cases
4) Explain deep learning and its strengths and challenges relative to other forms of machine learning
5) Implement best practices in evaluating and interpreting ML models

Tuesday, 16 January 2024

DevOps on AWS: Code, Build, and Test

 


What you'll learn

Understand the DevOps philosophies and its lifecycle

Implement and manage continuous delivery systems and methodologies on AWS

How to use the right tools to measure code quality by identifying workflow steps

Join Free: DevOps on AWS: Code, Build, and Test

There are 2 modules in this course

DevOps is the combination of cultural philosophies, practices, and tools that increases an organization’s ability to deliver applications and services at high velocity: evolving and improving products at a faster pace than organizations using traditional software development and infrastructure management processes. This speed enables organizations to better serve their customers and compete more effectively in the market.

DevOps process can be visualized as an infinite loop, comprising these steps: plan, code, build, test, release, deploy, operate, monitor. Throughout each phase, teams collaborate and communicate to maintain alignment, velocity, and quality. This course in the DevOps on AWS specialization focuses on code, build and test parts of the workflow. We will discuss topics such as source control, best practices for Continuous Integration, and how to use the right tools to measure code quality, by identifying workflow steps that could be automated.

Hands-on Machine Learning with AWS and NVIDIA

 


There are 4 modules in this course

Machine learning (ML) projects can be complex, tedious, and time consuming. AWS and NVIDIA solve this challenge with fast, effective, and easy-to-use capabilities for your ML project.

Join Free: Hands-on Machine Learning with AWS and NVIDIA

This course is designed for ML practitioners, including data scientists and developers, who have a working knowledge of machine learning workflows. In this course, you will gain hands-on experience on building, training, and deploying scalable machine learning models with Amazon SageMaker and Amazon EC2 instances powered by NVIDIA GPUs. Amazon SageMaker helps data scientists and developers prepare, build, train, and deploy high-quality ML models quickly by bringing together a broad set of capabilities purpose-built for ML. Amazon EC2 instances powered by NVIDIA GPUs along with NVIDIA software offer high performance GPU-optimized instances in the cloud for efficient model training and cost effective model inference hosting.

In this course, you will first get an overview of Amazon SageMaker and NVIDIA GPUs. Then, you will get hands-on, by running a GPU powered Amazon SageMaker notebook instance. You will then learn how to prepare a dataset for model training, build a model, execute model training, and deploy and optimize the ML model. You will also learn, hands-on, how to apply this workflow for computer vision (CV) and natural language processing (NLP) use cases. After completing this course, you will be able to build, train, deploy, and optimize ML workflows with GPU acceleration in Amazon SageMaker and understand the key Amazon SageMaker services applicable to computer vision and NLP ML tasks.

Introduction to Designing Data Lakes on AWS

 


What you'll learn

Where to start with a Data Lake?

How to build a secure and scalable Data Lake?

What are the common components of a Data Lake?

Why do you need a Data Lake and what it's value?

Join Free: Introduction to Designing Data Lakes on AWS

There are 4 modules in this course

In this class, Introduction to Designing Data Lakes on AWS, we will help you understand how to create and operate a data lake in a secure and scalable way, without previous knowledge of data science! Starting with the "WHY" you may want a data lake, we will look at the Data-Lake value proposition, characteristics and components.

Designing a data lake is challenging because of the scale and growth of data. Developers need to understand best practices to avoid common mistakes that could be hard to rectify. In this course we will cover the foundations of what a Data Lake is, how to ingest and organize data into the Data Lake, and dive into the data processing that can be done to optimize performance and costs when consuming the data at scale. This course is for professionals (Architects, System Administrators and DevOps) who need to design and build an architecture for secure and scalable Data Lake components. Students will learn about the use cases for a Data Lake and, contrast that with a traditional infrastructure of servers and storage.

Getting Started with Data Analytics on AWS

 


What you'll learn

Explain different types of data analyses – descriptive, diagnostic, predictive, prescriptive

Understand how to perform descriptive data analytics in the cloud with typical data sets

How to build simple visualizations in AWS QuickSight to do descriptive analytics (using S3, Cloudtrail, Athena)

Join Free: Getting Started with Data Analytics on AWS

There is 1 module in this course

Learn how to go from raw data to meaningful insights using AWS with this one-week course. Throughout the course, you’ll learn about the fundamentals of Data Analytics from AWS experts.

Start off with an overview of different types of data analytics techniques - descriptive, diagnostic, predictive, and prescriptive before diving deeper into the descriptive data analytics. Then, apply your knowledge with a guided project that makes use of a simple, but powerful dataset available by default in every AWS account: the logs from AWS CloudTrail. The CloudTrail service enables governance, compliance, operational auditing, and risk auditing of your AWS account. Through the project you’ll also get an introduction to Amazon Athena and Amazon QuickSight. And, you’ll learn how to build a basic security dashboard as a simple but practical method of applying your newfound data analytics knowledge.

DevOps on AWS Specialization

 


What you'll learn

Implement DevOps culture and practices in the AWS Cloud

Adopt and enforce Continuous Integration and Continuous

Delivery best practices on AWS

Explore deployment strategies for serverless applications

Join Free: DevOps on AWS Specialization

Specialization - 4 course series

DevOps on AWS specialization teaches you how to use the combination of DevOps philosophies, practices and tools to develop, deploy, and maintain applications in the AWS Cloud. Benefits of adopting DevOps include: rapid delivery, reliability, scalability, security and improved collaboration.

The first course introduces you to essential AWS products, services, and common solutions. The course covers the fundamental concepts of compute, database, storage, networking, monitoring and security that learners and professionals will need to know when working with AWS.

The second course in the specialization discusses topics such as source control, best practices for Continuous Integration, and how to use the right tools to measure code quality, by identifying workflow steps that could be automated.

The third course explains how to improve the deployment process with DevOps methodology, and also some tools that might make deployments easier, such as Infrastructure as Code, or IaC, and AWS CodeDeploy.

Finally, the last course teaches how to use Amazon CloudWatch for monitoring, as well as Amazon EventBridge and AWS Config for continuous compliance. It also covers Amazon CloudTrail and a little bit of Machine Learning for Monitoring operations.

Applied Learning Project

AWS provides a set of flexible services designed to enable companies to more rapidly and reliably build and deliver products using AWS and DevOps practices. These services simplify provisioning and managing infrastructure, deploying application code, automating software release processes, and monitoring your application and infrastructure performance. This specialization has a significant hands-on component involving the AWS Free Tier in which you will explore AWS services and concepts using AWS SDKs, AWS APIs, and the AWS Console.

Monday, 15 January 2024

Clean Architectures in Python (Free PDF)

 

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

What is a software architecture? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Why is it called “clean”? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Why “architectures”? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Why Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

About the book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Prerequisites and structure of the book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Typographic conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Why this book comes for free . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Submitting issues or patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

About the author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Changes in the second edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Chapter 01 A day in the life of a clean system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

The data flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Advantages of a layered architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Chapter 02 Components of a clean architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Chapter 03 A basic example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Chapter 04 Add a web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Flask setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Test and create an HTTP endpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

WSGI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

Chapter 05 Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Request and responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Basic structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Requests and responses in a use case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

Request validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Responses and failures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Error management in a use case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Integrating external systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Chapter 06 Integration with a real external system postgres . . . . . . . . . . . . . . . . . . . 89

Decoupling with interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

A repository based on PostgreSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Label integration tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Create SQLAlchemy classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Orchestration management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

Database fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Integration tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Chapter 07 Integration with a real external system mongodb . . . . . . . . . . . . . . . . . . 114

Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Docker Compose configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Application configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Integration tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

The MongoDB repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

Chapter 08 Run a production ready system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

Build a web stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

Connect to a production-ready database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

Colophon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

PDF Download: Clean Architectures in Python A practical approach to better software design




Understanding and Visualizing Data with Python

 


What you'll learn

Properly identify various data types and understand the different uses for each  

Create data visualizations and numerical summaries with Python

Communicate statistical ideas clearly and concisely to a broad audience

Identify appropriate analytic techniques for probability and non-probability samples

Join Free: Understanding and Visualizing Data with Python

There are 4 modules in this course

In this course, learners will be introduced to the field of statistics, including where data come from, study design, data management, and exploring and visualizing data. Learners will identify different types of data, and learn how to visualize, analyze, and interpret summaries for both univariate and multivariate data. Learners will also be introduced to the differences between probability and non-probability sampling from larger populations, the idea of how sample estimates vary, and how inferences can be made about larger populations based on probability sampling.

At the end of each week, learners will apply the statistical concepts they’ve learned using Python within the course environment. During these lab-based sessions, learners will discover the different uses of Python as a tool, including the Numpy, Pandas, Statsmodels, Matplotlib, and Seaborn libraries. Tutorial videos are provided to walk learners through the creation of visualizations and data management, all within Python. This course utilizes the Jupyter Notebook environment within Coursera.

Introduction to Structured Query Language (SQL)

 


What you'll learn

Learn about the basic syntax of the SQL language, as well as database design with multiple tables, foreign keys, and the JOIN operation.

Learn to model many-to-many relationships like those needed to represent users, roles, and courses.

Join Free: Introduction to Structured Query Language (SQL)

There are 4 modules in this course

In this course, you'll walk through installation steps for installing a text editor, installing MAMP or XAMPP (or equivalent) and creating a MySql Database. You'll learn about single table queries and the basic syntax of the SQL language, as well as database design with multiple tables, foreign keys, and the JOIN operation. Lastly, you'll learn to model many-to-many relationships like those needed to represent users, roles, and courses.

Survey Data Collection and Analytics Specialization

 


Advance your subject-matter expertise

Learn in-demand skills from university and industry experts

Master a subject or tool with hands-on projects

Develop a deep understanding of key concepts

Earn a career certificate from University of Michigan

Join Free: Survey Data Collection and Analytics Specialization

Specialization - 7 course series

This specialization covers the fundamentals of surveys as used in market research, evaluation research, social science and political research, official government statistics, and many other topic domains. In six courses, you will learn the basics of questionnaire design, data collection methods, sampling design, dealing with missing values, making estimates, combining data from different sources, and the analysis of survey data. In the final Capstone Project, you’ll apply the skills learned throughout the specialization by analyzing and comparing multiple data sources.


Faculty for this specialisation comes from the Michigan Program in Survey Methodology and the Joint Program in Survey Methodology, a collaboration between the University of Maryland, the University of Michigan, and the data collection firm Westat, founded by the National Science Foundation and the Interagency Consortium of Statistical Policy in the U.S.  to educate the next generation of survey researchers, survey statisticians, and survey methodologists. In addition to this specialization we offer short courses, a summer school, certificates, master degrees as well as PhD programs. 



Statistics with Python Specialization

 


What you'll learn

Create and interpret data visualizations using the Python programming language and associated packages & libraries

Apply and interpret inferential procedures when analyzing real data

Apply statistical modeling techniques to data (ie. linear and logistic regression, linear models, multilevel models, Bayesian inference techniques)

Understand importance of connecting research questions to data analysis methods.

Join Free: Statistics with Python Specialization

Specialization - 3 course series

This specialization is designed to teach learners beginning and intermediate concepts of statistical analysis using the Python programming language. Learners will learn where data come from, what types of data can be collected, study data design, data management, and how to effectively carry out data exploration and visualization. They will be able to utilize data for estimation and assessing theories, construct confidence intervals, interpret inferential results, and apply more advanced statistical modeling procedures. Finally, they will learn the importance of and be able to connect research questions to the statistical and data analysis methods taught to them.

Applied Learning Project

The courses in this specialization feature a variety of assignments that will test the learner’s knowledge and ability to apply content through concept checks, written analyses, and Python programming assessments. These assignments are conducted through quizzes, submission of written assignments, and the Jupyter Notebook environment.

User Experience Research and Design Specialization

 


What you'll learn

 Understand the basics of UX design and UX research

 Use appropriate UX research approaches to inform design decisions

 Design a complete product, taking it from an initial concept to an interactive prototype

Join Free: User Experience Research and Design Specialization

Specialization - 6 course series

Integrate UX Research and UX Design to create great products through understanding user needs, rapidly generating prototypes, and evaluating design concepts. Learners will gain hands-on experience with taking a product from initial concept, through user research, ideation and refinement, formal analysis, prototyping, and user testing, applying perspectives and methods to ensure a great user experience at every step.

Applied Learning Project

This Coursera specialization in UX Research and UX Design concludes with a capstone project, in which learners will incorporate UX Research and Design principles to design a complete product, taking it from an initial concept to an interactive prototype.

Sunday, 14 January 2024

Happy Makar Sankranti using Python

 


import turtle


# Set up the turtle
t = turtle.Turtle()
t.speed(2)
t.penup()

# Define scaling factor
scale_factor = 3.5

# Draw the kite
t.fillcolor("orange")
t.begin_fill()
t.goto(0, 100 * scale_factor)
t.goto(-100 * scale_factor, 0)
t.goto(0, 0)
t.end_fill()

t.fillcolor("pink")
t.begin_fill()
t.goto(100 * scale_factor, 0)
t.goto(0, 100 * scale_factor)
t.goto(0, 0)
t.end_fill()

t.fillcolor("cyan")
t.begin_fill()
t.goto(-100 * scale_factor, 0)
t.goto(0, -100 * scale_factor)
t.goto(0, 0)
t.end_fill()

t.fillcolor("green")
t.begin_fill()
t.goto(100 * scale_factor, 0)
t.goto(0, -100 * scale_factor)
t.end_fill()

t.fillcolor("yellow")
t.begin_fill()
t.goto(50 * scale_factor, -150 * scale_factor)
t.goto(-50 * scale_factor, -150 * scale_factor)
t.goto(0, -100 * scale_factor)
t.end_fill()

# Write text
t.penup()
t.goto(200, 100 * scale_factor)
t.write("Happy Makar Sankranti", align="center", font=("Arial", 16, "bold"))

# Close the turtle graphics window when clicked
turtle.exitonclick()

#clcoding.com

How much do you know about Intricacies Classes and Objects in Python?


 


a. A global function can call a class method as well as an instance method.

Answer

True

b. In Python a function, class, method and module are treated as objects.

Answer

True

c. Given an object, it is possible to determine its type and address.

Answer

True

d. It is possible to delete attributes of an object during execution of the

program.

Answer

True

e. Arithmetic operators, Comparison operators and Compound assignment

operators can be overloaded in Python.

Answer

True

f. The + operator has been overloaded in the classes str, list and int.

Answer

False

Saturday, 13 January 2024

A simple text-based guessing game in Python

 


import random


def guess_the_number():
    # Generate a random number between 1 and 100
    secret_number = random.randint(1, 100)

    print("Welcome to the Guess the Number game!")
    print("I have selected a number between 1 and 100. Can you guess it?")

    attempts = 0

    while True:
        try:
            # Get player's guess
            guess = int(input("Enter your guess: "))
            attempts += 1

            # Check if the guess is correct
            if guess == secret_number:
                print(f"Congratulations! You guessed the number in {attempts} attempts.")
                break
            elif guess < secret_number:
                print("Too low! Try again.")
            else:
                print("Too high! Try again.")

        except ValueError:
            print("Please enter a valid number.")

if __name__ == "__main__":
    guess_the_number()



Bar Graph plot using different Python Libraries


#!/usr/bin/env python
# coding: utf-8

# # 1. Using Matplotlib library

# In[1]:


import matplotlib.pyplot as plt

# Sample data
categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4']
values = [10, 25, 15, 30]

# Create a bar graph
plt.bar(categories, values)

# Adding labels and title
plt.xlabel('Categories')
plt.ylabel('Values')
plt.title('Bar Graph Example')

# Show the graph
plt.show()

#clcoding.com


# # 2. Using Seaborn library

# In[2]:


import seaborn as sns
import matplotlib.pyplot as plt

# Sample data
categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4']
values = [10, 25, 15, 30]

# Create a bar plot using Seaborn
sns.barplot(x=categories, y=values)

# Adding labels and title
plt.xlabel('Categories')
plt.ylabel('Values')
plt.title('Bar Plot Example')

# Show the plot
plt.show()
#clcoding.com


# # 3. Using Plotly library

# In[3]:


import plotly.express as px

# Sample data
categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4']
values = [10, 25, 15, 30]

# Create an interactive bar graph using Plotly
fig = px.bar(x=categories, y=values, labels={'x': 'Categories', 'y': 'Values'}, title='Bar Graph Example')

# Show the plot
fig.show()
#clcoding.com


# # 4. Using Bokeh library

# In[4]:


from bokeh.plotting import figure, show
from bokeh.io import output_notebook

# Sample data
categories = ['Category 1', 'Category 2', 'Category 3', 'Category 4']
values = [10, 25, 15, 30]

# Create a bar graph using Bokeh
p = figure(x_range=categories, title='Bar Graph Example', x_axis_label='Categories', y_axis_label='Values')
p.vbar(x=categories, top=values, width=0.5)

# Show the plot in a Jupyter Notebook (or use output_file for standalone HTML)
output_notebook()
show(p)
#clcoding.com


# In[ ]:






Python Workout: 50 ten-minute exercises

 


The only way to master a skill is to practice. In Python Workout, author Reuven M. Lerner guides you through 50 carefully selected exercises that invite you to flex your programming muscles. As you take on each new challenge, you’ll build programming skill and confidence.

Summary
The only way to master a skill is to practice. In Python Workout, author Reuven M. Lerner guides you through 50 carefully selected exercises that invite you to flex your programming muscles. As you take on each new challenge, you’ll build programming skill and confidence. The thorough explanations help you lock in what you’ve learned and apply it to your own projects. Along the way, Python Workout provides over four hours of video instruction walking you through the solutions to each exercise and dozens of additional exercises for you to try on your own.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
To become a champion Python programmer you need to work out, building mental muscle with your hands on the keyboard. Each carefully selected exercise in this unique book adds to your Python prowess—one important skill at a time.

About the book
Python Workout presents 50 exercises that focus on key Python 3 features. In it, expert Python coach Reuven Lerner guides you through a series of small projects, practicing the skills you need to tackle everyday tasks. You’ll appreciate the clear explanations of each technique, and you can watch Reuven solve each exercise in the accompanying videos.

What's inside

50 hands-on exercises and solutions
Coverage of all Python data types
Dozens more bonus exercises for extra practice

About the reader
For readers with basic Python knowledge.

About the author
Reuven M. Lerner teaches Python and data science to companies around the world.

Table of Contents

1 Numeric types

2 Strings

3 Lists and tuples

4 Dictionaries and sets

5 Files

6 Functions

7 Functional programming with comprehensions

8 Modules and packages

9 Objects

10 Iterators and generators

Hard Copy : Python Workout: 50 ten-minute exercises




Python Coding challenge - Day 115 | What is the output of the following Python Code?

 


Code :

list1 = [2, 3, 9, 12, 4]
list1.insert(4, 17)
list1.insert(2, 23)
print(list1[-4])  

Explanation:

Let's break down the code step by step:

Initial list: [2, 3, 9, 12, 4]
list1.insert(4, 17): Insert the value 17 at index 4. The list becomes [2, 3, 9, 12, 17, 4].
list1.insert(2, 23): Insert the value 23 at index 2. The list becomes [2, 3, 23, 9, 12, 17, 4].
print(list1[-4]): Print the element at the fourth position from the end of the list. The element at index -4 is 9.
So, the output of the code will be:

9

10 Levels of Writing Python Functions

Level 1: Basic Function

Level 2: Function with Parameters

Level 3: Return Values

Level 4: Default Parameters

Level 5: Docstrings

Level 6: Variable Scope

Level 7: Recursion

Level 8: Lambda Functions

Level 9: Function Decorators

Level 10: Advanced Functions







Friday, 12 January 2024

How much do you know about list in Python?



1. Which value is used to represent the first index of

list?

(a) 1 (b) 0

(c) −1 (d) a

Ans. (b) To access the list’s elements, index number is used. The

index number should be an integer. Index of 0 refers to first

element, 1 refers to second element and so on.


2. Choose the output of following Python code.

1= list ()

print ( 1)

(a) [] (b) ()

(c) [,] (d) Empty

Ans. (a) Empty list can be created in Python using []. To create

empty list, list () is also used.


3. Suppose list

1= [10, 20, 30, 40, 50, 60, 70]

print( 1[−3])

(a) 30 (b) 50

(c) 40 (d) Error

Ans. (b) The index of −1 refers to the last element, −2 refers to the

second last element and so on. Hence, −3 refers to third last

element, i.e. 50.


4. Choose the output from following code.

list1 = [‘A’, ‘R’, ‘I’,‘H’,‘A’,‘N’,‘T’]

print (list1 [7])

(a) T (b) N

(c) A (d) Error

Ans. (d) In the given code, we are trying to access 8th element

from the list which does not exist as we are having total 7

elements for which the last index is 6. So, Python will give

an IndexError.


5. Which function is used to insert an element at

specified position in the list?

(a) extend () (b) append ()

(c) insert () (d) add ()

Ans. (c) insert () function is used to insert an element at specified

position in the list. This method takes two arguments : one

for index number and second for element value.

Syntax list_name.insert(index, element)


6. Choose the correct option for the following.

l1 = [2, 5, 7]

l = l1+ 5

print (l)

(a) [7, 10, 12]

(b) [2, 5, 7, 5]

(c) [5, 2, 5, 7]

(d) TypeError

Ans. (d) + operator cannot add list with other type as number or

string because this operator is used only with list types.

So, it will give TypeError as it can only concatenate list (not

“int”) to list.


7. What is the output of following code?

l1 = [3, 2, 6]

l = l1 * 2

print (l)

(a) [3, 2, 6, 3, 2, 6]

(b) [6, 4, 12]

(c) [3, 4, 12]

(d) TypeError

Ans. (a) * operator can repeat the elements of the list.

Syntax list = list1 * digit


8. Which of the following is true regarding lists in

Python?

(a) Lists are immutable.

(b) Size of the lists must be specified before its initialisation.

(c) Elements of lists are stored in contiguous memory

location.

(d) size(list1) command is used to find the size of lists.

Ans. (c) Elements of lists are stored in contiguous memory

location, so it is true regarding lists in Python.


9. Suppose list1 is [56, 89, 75, 65, 99], what is the

output of list1 [− 2]?

(a) Error (b) 75

(c) 99 (d) 65

Ans. (d) −1 corresponds to the last index in the list, −2 represents

the second last element and so on.

So, the output for list1 [− 2] is 65 because 65 is second last

element of list1.


10. Identify the output of following code.

List1=[1, 2, 3, 7, 9]

L=List1.pop(9)

print(L)

(a) Syntax error (b) 9

(c) [1, 2, 3, 7] (d) None of these

Ans. (a) In pop(9), parentheses put index number instead of

element. In the given list, maximum index number is 4, then

9 is out of index range.


11. Suppose list1 is [2445,133,12454,123], what is the

output of max(list1)?

(a) 2445 (b) 133

(c) 12454 (d)123

Ans. (c) max() returns the maximum element in the list. From

given options, 12454 is the element with maximum value.


12. To add a new element to a list, which command will

we use?

(a) list1.add(8)

(b) list1.append(8)

(c) list1.addLast(8)

(d) list1.addEnd(8)

Ans. (b) We use the function append() to add an element to the list.


13. What will be the output of the following Python

code?

list1=[9, 5, 3, 5, 4]

list1[1:2]=[7,8]

print(list1)

(a) [9,5, 3, 7, 8] (b) [9, 7, 8, 3, 5, 4]

(c) [9,[ 7, 8], 3, 5,4] (d) Error

Ans. (b) In the piece of code, slice assignment has been

implemented. The sliced list is replaced by the assigned

elements in the list.


14. Consider the declaration a=[2, 3, ‘Hello’, 23.0].

Which of the following represents the data type of

‘a’?

(a) String (b) Tuple

(c) Dictionary (d) List

Ans. (d) List contains a sequence of heterogeneous elements

which store integer, string as well as object. It can created to

put elements separated by comma (,) in square brackets [].


15. Identify the output of the following Python

statement.

x=[[1, 2, 3, 4], [5, 6, 7, 8]]

y=x [0] [2]

print(y)

(a) 3 (b) 4

(c) 6 (d) 7

Ans. (a) x is a list, which has two sub-lists in it. Elements of first

list will be represented by [0] [i] and elements of second list

will be represented by [1] [i].


16. Which method will empty the entire list?

(a) pop() (b) clear()

(c) sort() (d) remove()

Ans. (b) clear() method is used to remove all the items of a list.

This method will empty the entire list.

Syntax

list_name.clear()


17. Which of the following allows us to sort the list

elements in descending order?

(a) reverse = True

(b) reverse = False

(c) sort (descending)

(d) sort. descending

Ans. (a) sort() is used to sort the given list in ascending order. The

sort() has an argument called reverse = True. This allows us

to sort the list elements in descending order.


18. Identify the correct output.

>>>l1 = [34, 65, 23, 98]

>>>l1. insert(2, 55)

>>>l1

(a) [34, 65, 23, 55] (b) [34, 55, 65, 23, 98]

(c) [34, 65, 55, 98] (d) [34, 65, 55, 23, 98]

Ans. (d) insert() is used to insert an element at specified position

in the list. This method takes two arguments : one for index

number and second for element value.

Syntax

list_name.insert(index, element)


19. Find the output from the following code.

list1=[2, 5, 4, 7, 7, 7, 8, 90]

del list1[2 : 4]

print(list1)

(a) [2, 5, 7, 7, 8, 90] (b) [5, 7, 7, 7, 8, 90]

(c) [2, 5, 4, 8, 90] (d) Error

Ans. (a) del keyword is used to delete the elements from the list.


20. Slice operation is performed on lists with the use of

(a) semicolon (b) comma

(c) colon (d) hash

Ans. (c) In Python list, there are multiple ways to print the whole

list with all the elements, but to print a specific range of

elements from the list, we use slice operation. Slice

operation is performed on lists with the use of colon (:).

Play Fidget Spinner game using Python




from turtle import *

speed(0)
bgcolor('lightgray')
title('Fidget Spinner Game')

spinner_radius = 250  # Increased radius
spinner_speed = 0
spinner_colors = ['red', 'green', 'blue']

def create_spinner():
    penup()
    goto(0, 0)  # Center the spinner
    pendown()

    for color in spinner_colors:
        fillcolor(color)
        begin_fill()
        circle(spinner_radius/len(spinner_colors))
        end_fill()
        right(360 / len(spinner_colors))

def spin_spinner(x, y):
    global spinner_speed
    spinner_speed += 10

def stop_spinner(x, y):
    global spinner_speed
    spinner_speed = max(0, spinner_speed - 5)

def animate_spinner():
    global spinner_speed
    clear()
    create_spinner()
    right(spinner_speed)
    update()
    ontimer(animate_spinner, 20)

def main():
    setup(600, 600)
    hideturtle()
    tracer(False)
   
    create_spinner()

    onscreenclick(spin_spinner, 1)
    onscreenclick(stop_spinner, 3)

    animate_spinner()

    done()

if __name__ == "__main__":
    main()

What is the output of following Python code?

 What is the output of following Python code?


a =[[0, 1, 2], [3, 4, 5, 6]]

b =a[1] [2]

print (b)

Answer with Explanation:

Let's break down your code step by step:

a = [[0, 1, 2], [3, 4, 5, 6]]

Here, you have defined a list a that contains two sub-lists. The first sub-list is [0, 1, 2], and the second sub-list is [3, 4, 5, 6]. So, a is a list of lists.

b = a[1][2]

This line of code is accessing elements in the nested list. Let's break it down:


a[1] accesses the second sub-list in a. In Python, indexing starts from 0, so a[1] refers to [3, 4, 5, 6].

[2] then accesses the third element in this sub-list. Again, indexing starts from 0, so a[1][2] refers to the element at index 2 in the sub-list [3, 4, 5, 6].

As a result, b is assigned the value 5, which is the third element in the second sub-list.

print(b)

Finally, the print(b) statement outputs the value of b, which is 5, to the console.

So, when you run this code, the output will be:

5

This is because b contains the value at index [1][2] in the nested list a, which is 5.

Python Coding challenge - Day 114 | What is the output of the following Python Code?

 


Code: 

def fun(num):

    if num > 10:

        return num - 10

    return fun(fun(num + 11))

print(fun(5))

Solution and Explanantion: 


The output of the code is 1.

Here's a breakdown of how the code works:

Function Definition:

The code defines a recursive function named fun that takes a single argument, num.

Base Case:

The if statement checks if num is greater than 10. If it is, the function returns num - 10. This is the base case that stops the recursion.

Recursive Calls:

If num is not greater than 10, the function calls itself twice, creating two recursive calls:
fun(fun(num + 11))
The inner call fun(num + 11) adds 11 to num and passes the result to the fun function again.
The outer call takes the result of the inner call and passes it to the fun function once more.

Execution Flow:

When you call fun(5), here's what happens:
5 is not greater than 10, so the function calls fun(fun(16)).
The inner call fun(16) now executes. 16 is greater than 10, so the base case triggers and returns 16 - 10 = 6.
The outer call now has 6 as its argument. 6 is not greater than 10, so it calls fun(fun(17)).
The inner call fun(17) executes. 17 is greater than 10, so the base case returns 17 - 10 = 7.
The outer call now has 7 as its argument. 7 is not greater than 10, so it calls fun(fun(18)).
This process continues until fun(25) is reached. At this point, the base case returns 25 - 10 = 15.
The values start propagating back through the recursive calls, eventually leading to the final return value of 1.
Key Points:

The code demonstrates recursion, where a function calls itself within its own definition.
The base case is crucial to prevent infinite recursion and ensure the function eventually terminates.
Recursive functions can be helpful for solving problems that can be broken down into smaller, self-similar subproblems. 

Popular Posts

Categories

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (358) Python Quiz (23) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses