Thursday 16 November 2023

Machine Learning with Python


What you'll learn

Describe the various types of Machine Learning algorithms and when to use them  

Compare and contrast linear classification methods including multiclass prediction, support vector machines, and logistic regression  

Write Python code that implements various classification techniques including K-Nearest neighbors (KNN), decision trees, and regression trees 

Evaluate the results from simple linear, non-linear, and multiple regression on a data set using evaluation metrics  

 There are 6 modules in this course

Get ready to dive into the world of Machine Learning (ML) by using Python! This course is for you whether you want to advance your Data Science career or get started in Machine Learning and Deep Learning.  

This course will begin with a gentle introduction to Machine Learning and what it is, with topics like supervised vs unsupervised learning, linear & non-linear regression, simple regression and more.  

You will then dive into classification techniques using different classification algorithms, namely K-Nearest Neighbors (KNN), decision trees, and Logistic Regression. You’ll also learn about the importance and different types of clustering such as k-means, hierarchical clustering, and DBSCAN. 

With all the many concepts you will learn, a big emphasis will be placed on hands-on learning. You will work with Python libraries like SciPy and scikit-learn and apply your knowledge through labs. In the final project you will demonstrate your skills by building, evaluating and comparing several Machine Learning models using different algorithms.  

By the end of this course, you will have job ready skills to add to your resume and a certificate in machine learning to prove your competency.

Join free - Machine Learning with Python

Wednesday 15 November 2023

Python Coding challenge - Day 70 | What is the output of the following Python code?


a == c: This checks if the values of a and c are equal. The values of both lists are [1, 2, 3], so a == c is True.

a is c: This checks if a and c refer to the exact same object. As mentioned before, although the values of the lists are the same, a and c are two different list objects. Therefore, a is c is False.

So, the output of this code will be: True, False

Tuesday 14 November 2023

result = max(-0.0, 0.0) print(result)

result = max(-0.0, 0.0) 

The correct explanation is that in Python, -0.0 and 0.0 are considered equal, and the max() function does not distinguish between them based on sign. When you use max(-0.0, 0.0), the result will be the number with the higher magnitude, regardless of its sign. In this case, both -0.0 and 0.0 have the same magnitude, so the result will be the one that appears first in the arguments, which is -0.0:

result = max(-0.0, 0.0)




So, max(-0.0, 0.0) returns -0.0 due to the way Python handles the comparison of floating-point numbers.

round(3 / 2) round(5 / 2)

 The round() function is used to round a number to the nearest integer. Let's calculate the results:

round(3 / 2) is equal to round(1.5), and when rounded to the nearest integer, it becomes 2.

round(5 / 2) is equal to round(2.5), and when rounded to the nearest integer, it becomes 2.

So, the results are:

round(3 / 2) equals 2.

round(5 / 2) equals 2.

Why does round(5 / 2) return 2 instead of 3? The issue here is that Python’s round method implements banker’s rounding, where all half values will be rounded to the closest even number. 

The most difficult Python questions:

  • What is the Global Interpreter Lock (GIL)? Why is it important?
  • Define self in Python?
  • What is pickling and unpickling in Python?
  • How do you reverse a list in Python?
  • What does break and continue do in Python?
  • Can break and continue be used together?
  • Explain generators vs iterators.
  • How do you access a module written in Python from C?
  • What is the difference between a List and a Tuple?
  • What is __init__() in Python?
  • What is the difference between a mutable data type and an immutable data type?
  • Explain List, Dictionary, and Tuple comprehension with an example.
  • What is monkey patching in Python?
  • What is the Python “with” statement designed for?
  • Why use else in try/except construct in Python?
  • What are the advantages of NumPy over regular Python lists?
  • What is the difference between merge, join and concatenate?
  • How do you identify and deal with missing values?
  • Which all Python libraries have you used for visualization?
  • What is the most difficult Python question you have ever encountered?

Python: Lists vs. Tuples vs. Sets vs. Dictionaries

 lists, tuples, sets, and dictionaries in Python based on various characteristics:


Lists: Mutable. You can modify, add, or remove elements after creation.

Tuples: Immutable. Once created, elements cannot be changed.

Sets: Mutable. You can add or remove elements, but each element must be unique.

Dictionaries: Mutable. You can add, modify, or remove key-value pairs.


Lists: Ordered. Elements are stored in a specific order and can be accessed by index.

Tuples: Ordered. Similar to lists, elements have a specific order.

Sets: Unordered. Elements have no specific order, and you cannot access them by index.

Dictionaries: Prior to Python 3.7, dictionaries were unordered. From Python 3.7 onwards, dictionaries maintain insertion order.


Lists: Can contain duplicate elements.

Tuples: Can contain duplicate elements.

Sets: Cannot contain duplicate elements.

Dictionaries: Keys must be unique.


Lists: Defined using square brackets [].

Tuples: Defined using parentheses ().

Sets: Defined using curly braces {}.

Dictionaries: Defined using curly braces {} with key-value pairs separated by colons.

Use Cases:

Lists: Use when you need a mutable, ordered collection with the possibility of duplicate elements.

Tuples: Use when you need an immutable, ordered collection. Suitable for situations where data should not be changed.

Sets: Use when you need an unordered collection of unique elements and order doesn't matter.

Dictionaries: Use when you need a mutable collection of key-value pairs, providing fast lookup based on keys.


my_list = [1, 2, 3]

my_tuple = (4, 5, 6)

my_set = {7, 8, 9}

my_dict = {'a': 10, 'b': 11, 'c': 12}

IBM Full Stack Software Developer Professional Certificate


Prepare for a career as a full stack developer. Gain the in-demand skills and hands-on experience to get job-ready in less than 4 months. No prior experience required.

What you'll learn

Master the most up-to-date practical skills and tools that full stack developers use in their daily roles

Learn how to deploy and scale applications using Cloud Native methodologies and tools such as Containers, Kubernetes, Microservices, and Serverless

Develop software with front-end development languages and tools such as HTML, CSS, JavaScript, React, and Bootstrap

Build your GitHub portfolio by applying your skills to multiple labs and hands-on projects, including a capstone

Professional Certificate - 12 course series

Prepare for a career in the high-growth field of software development. In this program, you’ll learn in-demand skills and tools used by professionals for front-end, back-end, and cloud native application development to get job-ready in less than 4 months, with no prior experience needed. 

Full stack refers to the end-to-end computer system application, including the front end and back end coding. This Professional Certificate covers development for both of these scenarios. Cloud native development refers to developing a program designed to work on cloud architecture. The flexibility and adaptability that full stack and cloud native developers provide make them highly sought after in this digital world. 

You’ll  learn how to build, deploy, test, run, and manage full stack cloud native applications. Technologies covered includes Cloud foundations, GitHub, Node.js, React, CI/CD, Containers, Docker, Kubernetes, OpenShift, Istio, Databases, NoSQL, Django ORM, Bootstrap, Application Security, Microservices, Serverless computing, and more. 

After completing the program you will have developed several applications using front-end and back-end technologies and deployed them on a cloud platform using Cloud Native methodologies. You will publish these projects through your GitHub repository to share your portfolio with your peers and prospective employers.

This program is ACE® recommended—when you complete, you can earn up to 18 college credits.

Applied Learning Project

Throughout the courses in the Professional Certificate, you will develop a portfolio of hands-on projects involving various popular technologies and programming languages in Full Stack Cloud Application Development. These projects include creating:

HTML pages on Cloud Object Storage

An interest rate calculator using HTML, CSS, and JavaScript

An AI program deployed on Cloud Foundry using DevOps principles and CI/CD toolchains with a NoSQL database

A Node.js back-end application and a React front-end application

A containerized guestbook app packaged with Docker deployed with Kubernetes and managed with OpenShift

A Python app bundled as a package

A database-powered application using Django ORM and Bootstrap

An app built using Microservices & Serverless

A scalable, Cloud Native Full Stack application using the technologies learned in previous courses

You will publish these projects through your GitHub repository to share your skills with your peers and prospective employers.

Join - IBM Full Stack Software Developer Professional Certificate

Object-Oriented Python: Inheritance and Encapsulation


What you'll learn

How to architect larger programs using object-oriented principles

Re-use parts of classes using inheritance

Encapsulate relevant information and methods in a class

There are 4 modules in this course

Code and run your first python program in minutes without installing anything!

This course is designed for learners with limited coding experience, providing a solid foundation of not just python, but core Computer Science topics that can be transferred to other languages. The modules in this course cover inheritance, encapsulation, polymorphism, and other object-related topics. Completion of the prior 3 courses in this specialization is recommended.

To allow for a truly hands-on, self-paced learning experience, this course is video-free. Assignments contain short explanations with images and runnable code examples with suggested edits to explore code examples further, building a deeper understanding by doing. You'll benefit from instant feedback from a variety of assessment items along the way, gently progressing from quick understanding checks (multiple choice, fill in the blank, and un-scrambling code blocks) to small, approachable coding exercises that take minutes instead of hours.

Join free - Object-Oriented Python: Inheritance and Encapsulation

Python Coding challenge - Day 69 | What is the output of the following Python code?


The above code of the list my_list using slicing and assigns a new set of values [7, 8, 9] to the sliced portion. Here's a step-by-step breakdown:

my_list = [1, 2, 3, 4, 5]

This initializes a list with the values [1, 2, 3, 4, 5].

my_list[1:3] = [7, 8, 9]

This slices the elements at index 1 and 2 (exclusive) of my_list and replaces them with the values [7, 8, 9]. After this line executes, my_list becomes [1, 7, 8, 9, 4, 5].


This prints the modified list:

[1, 7, 8, 9, 4, 5]

So, the final output is [1, 7, 8, 9, 4, 5].

Monday 13 November 2023

Python Coding challenge - Day 68 | What is the output of the following Python code?


The expression 3 * 2 ** 3 involves exponentiation and multiplication. The exponentiation operator ** has higher precedence than multiplication.

Let's break it down step by step:

3. 2∗∗32∗∗3 is 2×2×22×2×2, which equals 88.

4. 3×83×8 is 2424.

So, the output of the code: print(3 * 2 ** 3)


Do you know the reason ?


The all function returns True if all elements of the iterable are true (or if the iterable is empty). If any element is false, it returns False.

In the case of an empty iterable, such as an empty list ([]), the all function returns True because there are no elements that are false.

So, when you execute print(all([])), it will output: True

The any function returns True if at least one element of the iterable is true. If the iterable is empty, it returns False because there are no elements to evaluate.

In the case of an empty iterable, such as an empty list ([]), the any function returns False.

So, when you execute print(any([])), it will output: False

A simple Python code for checking whether a given number is prime or not


def is_prime(number):

    # Check if the number is less than 2

    if number < 2:

        return False


    # Check for factors from 2 to the square root of the number

    for i in range(2, int(number**0.5) + 1):

        if number % i == 0:

            # If a factor is found, the number is not prime

            return False


    # If no factors are found, the number is prime

    return True

# Example usage

num = int(input("Enter a number: "))

if is_prime(num):

    print(f"{num} is a prime number.")


    print(f"{num} is not a prime number.")


The is_prime function takes an integer number as an argument and returns True if the number is prime, and False otherwise.

The function first checks if the number is less than 2. If it is, the number is not prime, as prime numbers are defined as greater than 1.

It then uses a for loop to iterate over the range from 2 to the square root of the number (rounded up to the nearest integer). This is an optimization, as factors of a number larger than its square root must pair with factors smaller than its square root.

Inside the loop, it checks if the number is divisible evenly by the current value of i. If it is, then the number is not prime, and the function returns False.

If no factors are found in the loop, the function returns True, indicating that the number is prime.

Finally, an example usage of the function is shown, where the user is prompted to enter a number, and the program prints whether it is prime or not based on the result of the is_prime function.

Count number of files and directories


import os

# Path IN which we have to count files and directories

PATH = 'E:\elements'   # Give your path here

fileCount = 0

dirCount = 0

for root, dirs, files in os.walk(PATH):

    print('Looking in:',root)

    for directories in dirs:

        dirCount += 1

    for Files in files:

        fileCount += 1

print('Number of files',fileCount)

print('Number of Directories',dirCount)

print('Total:',(dirCount + fileCount))

Sunday 12 November 2023

Introduction to Python


What you'll learn

Uses of Python

Python variables and input

Python Decisions and Looping

About this Guided Project

Learning Python gives the programmer a wide variety of career paths to choose from. Python is an open-source (free) programming language that is used in web programming, data science, artificial intelligence, and many scientific applications. Learning Python allows the programmer to focus on solving problems, rather than focusing on syntax. Its relative size and simplified syntax give it an edge over languages like Java and C++, yet the abundance of libraries gives it the power needed to accomplish great things.

In this tutorial you will create a guessing game application that pits the computer against the user. You will create variables, decision constructs, and loops in python to create the game.

Learn step-by-step

In a video that plays in a split-screen with your work area, your instructor will walk you through these steps:

  • Task 1: How Python is Used

  • Task 2: Python Input and variables

  • Task3: Python Decisions

  • Challenge Task: Python Input and Decisions

  • Challenge Solution: Python Input and Decisions

  • Task 4: Python Loops

  • Task 5: Python Functions

  • Challenge Task: Python While Loops and Functions

  • Challenge Solution: Python While Loops and Functions

Join - Introduction to Python

Understanding Basic SQL Syntax


What you'll learn

Identify and use correct syntax when writing SQL retrieval queries.

Learn, practice, and apply job-ready skills in less than 2 hours

Receive training from industry experts

Gain hands-on experience solving real-world job tasks

Build confidence using the latest tools and technologies

About this Guided Project

In this project you will learn to identify and use correct syntax when writing SQL retrieval queries. Through hands-on activities in SQLiteStudio, you will gain experience with the SQL syntax used to display specific columns, filter for specific rows, and determine the sequence of those columns and rows in query output. Familiarity with SQL syntax is a marketable skill for both Information Technology professionals and non-IT super users.

Learn step-by-step

In a video that plays in a split-screen with your work area, your instructor will walk you through these steps:

•Describe basic SQL syntax rules along with requirements for the names of tables, and the naming and data type requirements for table columns (fields).

•Use the SELECT command and FROM clause to control the columns that are displayed and the order in which they display in query output.

•Limit the rows retrieved by an SQL query by applying the WHERE clause with one or more conditions.

•Use the ORDER BY clause to modify the sort order of the rows returned from an SQL retrieval query.

•Code an SQL retrieval query that uses the JOIN command to retrieve data rows from tables that are related via a common column.

Join - Understanding Basic SQL Syntax

Python Coding challenge - Day 67 | What is the output of the following Python code?


In Python, the True Boolean value is equivalent to the integer 1, and False is equivalent to 0. Therefore, when you multiply True by any number, it's like multiplying 1 by that number.

In this code: print(True * 10)

It will output 10 because True is equivalent to 1, and 1 * 10 equals 10.

Successful Algorithmic Trading halls-moore (PDF)


Introduction to the Book

1.1 Introduction to QuantStart

QuantStart was founded by Michael Halls-Moore, in 2010, to help junior quantitative analysts

(QAs) find jobs in the tough economic climate. Since then the site has evolved to become a

substantial resource for quantitative finance. The site now concentrates on algorithmic trading,

but also discusses quantitative development, in both Python and C++.

Since March 2010, QuantStart has helped over 200,000 visitors improve their quantitative

finance skills. You can always contact QuantStart by sending an email to

1.2 What is this Book?

Successful Algorithmic Trading has been written to teach retail discretionary traders and trading

professionals, with basic programming skills, how to create fully automated profitable and robust

algorithmic trading systems using the Python programming language. The book describes the

nature of an algorithmic trading system, how to obtain and organise financial data, the concept of backtesting and how to implement an execution system. The book is designed to be

extremely practical, with liberal examples of Python code throughout the book to demonstrate

the principles and practice of algorithmic trading.

1.3 Who is this Book For?

This book has been written for both retail traders and professional quants who have some basic

exposure to programming and wish to learn how to apply modern languages and libraries to

algorithmic trading. It is designed for those who enjoy self-study and can learn by example. The

book is aimed at individuals interested in actual programming and implementation, as I believe

that real success in algorithmic trading comes from fully understanding the implementation


Professional quantitative traders will also find the content useful. Exposure to new libraries

and implementation methods may lead to more optimal execution or more accurate backtesting.

1.4 What are the Prerequisites?

The book is relatively self-contained, but does assume a familiarity with the basics of trading in

a discretionary setting. The book does not require an extensive programming background, but

basic familiarity with a programming language is assumed. You should be aware of elementary

programming concepts such as variable declaration, flow-control (if-else) and looping (for/while).

Some of the trading strategies make use of statistical machine learning techniques. In addition, the portfolio/strategy optimisation sections make extensive use of search and optimization.

PDF Link - successful algorithmic trading halls-moore

Understanding Deep Learning (PDF Book)


Deep learning is a fast-moving field with sweeping relevance in today’s increasingly digital world. Understanding Deep Learning provides an authoritative, accessible, and up-to-date treatment of the subject, covering all the key topics along with recent advances and cutting-edge concepts. Many deep learning texts are crowded with technical details that obscure fundamentals, but Simon Prince ruthlessly curates only the most important ideas to provide a high density of critical information in an intuitive and digestible form. From machine learning basics to advanced models, each concept is presented in lay terms and then detailed precisely in mathematical form and illustrated visually. The result is a lucid, self-contained textbook suitable for anyone with a basic background in applied mathematics.

Up-to-date treatment of deep learning covers cutting-edge topics not found in existing texts, such as transformers and diffusion models

Short, focused chapters progress in complexity, easing students into difficult concepts

Pragmatic approach straddling theory and practice gives readers the level of detail required to implement naive versions of models

Streamlined presentation separates critical ideas from background context and extraneous detail

Minimal mathematical prerequisites, extensive illustrations, and practice problems make challenging material widely accessible

Programming exercises offered in accompanying Python Notebooks

Buy - Understanding Deep Learning

PDF Link - Understanding Deep Learning (PDF )

Understanding Machine Learning: From Theory to Algorithms (PDF Book)


Machine learning is one of the fastest growing areas of computer science, with far-reaching applications. The aim of this textbook is to introduce machine learning, and the algorithmic paradigms it offers, in a principled way. The book provides an extensive theoretical account of the fundamental ideas underlying machine learning and the mathematical derivations that transform these principles into practical algorithms. Following a presentation of the basics of the field, the book covers a wide array of central topics that have not been addressed by previous textbooks. These include a discussion of the computational complexity of learning and the concepts of convexity and stability; important algorithmic paradigms including stochastic gradient descent, neural networks, and structured output learning; and emerging theoretical concepts such as the PAC-Bayes approach and compression-based bounds. Designed for an advanced undergraduate or beginning graduate course, the text makes the fundamentals and algorithms of machine learning accessible to students and non-expert readers in statistics, computer science, mathematics, and engineering.

Buy - Understanding Machine Learning: From Theory to Algorithms 

PDF Link - Understanding Machine Learning: From Theory to Algorithms

Saturday 11 November 2023

Happy Diwali using Python Turtle


import turtle

s = turtle.Screen()

t = turtle.Turtle()

def move_to(x,y):




def draw_rectangle(a,b):
















































































































for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):








for i in range(20):





Mastering Data Analysis with Pandas


What you'll learn

Master data analysis and manipulation in Pandas and Python

Define and manipulate Pandas Series

Master Pandas Attributes, methods and math operations

Project Link - Mastering Data Analysis with Pandas

About this Guided Project

In this structured series of hands-on guided projects, we will master the fundamentals of data analysis and manipulation with Pandas and Python. Pandas is a super powerful, fast, flexible and easy to use open-source data analysis and manipulation tool. This guided project is the first of a series of multiple guided projects (learning path) that is designed for anyone who wants to master data analysis with pandas.

Learn step-by-step

In a video that plays in a split-screen with your work area, your instructor will walk you through these steps:

•Introduction and Pandas Series Fundamentals

•Define a Pandas Series with Custom Index

•Define a Pandas Series from a Dictionary 

•Pandas Attributes

•Pandas Methods

•Import One Dimensional CSV Data 

•Pandas Built-in Functions

•Sorting Pandas Series

•Perform Math Operations on Pandas Series

•Check if a Given Element Exists in a Pandas Series

Python Coding challenge - Day 66 | What is the output of the following Python code?


In Python, when you multiply a boolean value by an integer, the boolean value is implicitly converted to an integer. In this case, False is equivalent to 0, so False * 10 will result in 0.

If you run the following code: print(False * 10)

The output will be: 0

Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems (Free PDF)


Through a recent series of breakthroughs, deep learning has boosted the entire field of machine learning. Now, even programmers who know close to nothing about this technology can use simple, efficient tools to implement programs capable of learning from data. This bestselling book uses concrete examples, minimal theory, and production-ready Python frameworks (Scikit-Learn, Keras, and TensorFlow) to help you gain an intuitive understanding of the concepts and tools for building intelligent systems.

With this updated third edition, author Aurélien Géron explores a range of techniques, starting with simple linear regression and progressing to deep neural networks. Numerous code examples and exercises throughout the book help you apply what you've learned. Programming experience is all you need to get started.

Use Scikit-learn to track an example ML project end to end

Explore several models, including support vector machines, decision trees, random forests, and ensemble methods

Exploit unsupervised learning techniques such as dimensionality reduction, clustering, and anomaly detection

Dive into neural net architectures, including convolutional nets, recurrent nets, generative adversarial networks, autoencoders, diffusion models, and transformers

Use TensorFlow and Keras to build and train neural nets for computer vision, natural language processing, generative models, and deep reinforcement learning 

Buy - Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems

PDF Link - 

Computers, Waves, Simulations: A Practical Introduction to Numerical Methods using Python (Free Course)


What you'll learn

How to solve a partial differential equation using the finite-difference, the pseudospectral, or the linear (spectral) finite-element method.

Understanding the limits of explicit space-time simulations due to the stability criterion and spatial and temporal sampling requirements.

Strategies how to plan and setup sophisticated simulation tasks.

Strategies how to avoid errors in simulation results. 

There are 9 modules in this course

Interested in learning how to solve partial differential equations with numerical methods and how to turn them into python codes? This course provides you with a basic introduction how to apply methods like the finite-difference method, the pseudospectral method, the linear and spectral element method to the 1D (or 2D) scalar wave equation. The mathematical derivation of the computational algorithm is accompanied by python codes embedded in Jupyter notebooks. In a unique setup you can see how the mathematical equations are transformed to a computer code and the results visualized. The emphasis is on illustrating the fundamental mathematical ingredients of the various numerical methods (e.g., Taylor series, Fourier series, differentiation, function interpolation, numerical integration) and how they compare. You will be provided with strategies how to ensure your solutions are correct, for example benchmarking with analytical solutions or convergence tests. The mathematical aspects are complemented by a basic introduction to wave physics, discretization, meshes, parallel programming, computing models. 

The course targets anyone who aims at developing or using numerical methods applied to partial differential equations and is seeking a practical introduction at a basic level. The methodologies discussed are widely used in natural sciences,  engineering, as well as economics and other fields. 

Join - Computers, Waves, Simulations: A Practical Introduction to Numerical Methods using Python

20 extremely useful single-line Python codes


#!/usr/bin/env python

# coding: utf-8

# # 20 extremely useful single-line Python codes

# #  1.  Swap Variables:

# In[ ]:

a, b = b, a

# # 2. Find Maximum Element in a List:

# In[ ]:

max_element = max(lst)

# # 3. Find Minimum Element in a List:

# In[ ]:

min_element = min(lst)

# # 4. List Comprehension:

# In[ ]:

squared_numbers = [x**2 for x in range(10)]

# # 5. Filter List Elements:

# In[ ]:

even_numbers = list(filter(lambda x: x % 2 == 0, lst))

# # 6. Map Function:

# In[ ]:

doubled_numbers = list(map(lambda x: x * 2, lst))

# # 7. Sum of List Elements:

# In[ ]:

total = sum(lst)

# # 8. Check if All Elements in a List are True:

# In[ ]:

all_true = all(lst)

# # 9. Check if Any Element in a List is True:

# In[ ]:

any_true = any(lst)

# # 10. Count Occurrences of an Element in a List:

# In[ ]:

count = lst.count(element)

# # 11. Reverse a String:

# In[ ]:

reversed_str = my_str[::-1]

# # 12. Read a File into a List of Lines:

# In[ ]:

lines = [line.strip() for line in open('file.txt')]

# # 13. Inline If-Else:

# In[ ]:

result = "even" if x % 2 == 0 else "odd"

# # 14. Flatten a Nested List:

# In[ ]:

flat_list = [item for sublist in nested_list for item in sublist]

# # 15. Find the Factorial of a Number:

# In[ ]:

factorial = 1 if n == 0 else functools.reduce(lambda x, y: x * y, range(1, n+1))

# # 16. List Unique Elements:

# In[ ]:

unique_elements = list(set(lst))

# # 17. Execute a Function for Each Element in a List:

# In[ ]:

result = list(map(lambda x: my_function(x), lst))

# # 18. Calculate the Average of a List:

# In[ ]:

average = sum(lst) / len(lst) if len(lst) > 0 else 0

# # 19. Convert a String to a List of Characters:

# In[ ]:

char_list = list("hello")

# # 20. Find Common Elements Between Two Lists:

# In[ ]:

common_elements = list(set(lst1) & set(lst2))

# In[ ]:

Friday 10 November 2023

Get Started with Stacks and Queues in Python


Stacks and queues are fundamental data structures used in computer science to manage and organize data. Let's get started with stacks and queues in Python.


A stack is a Last In, First Out (LIFO) data structure, where the last element added is the first one to be removed. Think of it like a stack of plates - you can only take the top plate off.

Implementation in Python:

class Stack:
    def __init__(self):
        self.items = []

    def is_empty(self):
        return len(self.items) == 0

    def push(self, item):

    def pop(self):
        if not self.is_empty():
            return self.items.pop()
            raise IndexError("pop from an empty stack")

    def peek(self):
        if not self.is_empty():
            return self.items[-1]
            raise IndexError("peek from an empty stack")

    def size(self):
        return len(self.items)

Example usage:

stack = Stack()

print("Stack:", stack.items)

print("Pop:", stack.pop())
print("Stack after pop:", stack.items)

print("Peek:", stack.peek())
print("Stack size:", stack.size())


A queue is a First In, First Out (FIFO) data structure, where the first element added is the first one to be removed. Think of it like a queue of people waiting in line.

Implementation in Python:

class Queue:
    def __init__(self):
        self.items = []

    def is_empty(self):
        return len(self.items) == 0

    def enqueue(self, item):

    def dequeue(self):
        if not self.is_empty():
            return self.items.pop(0)
            raise IndexError("dequeue from an empty queue")

    def front(self):
        if not self.is_empty():
            return self.items[0]
            raise IndexError("front from an empty queue")

    def size(self):
        return len(self.items)

Example usage:

queue = Queue()

print("Queue:", queue.items)

print("Dequeue:", queue.dequeue())
print("Queue after dequeue:", queue.items)

print("Front:", queue.front())
print("Queue size:", queue.size())

These basic implementations should get you started with stacks and queues in Python. Feel free to modify and expand upon them based on your specific needs.

Programming for Everybody (Getting Started with Python)


What you'll learn

Install Python and write your first program

Describe the basics of the Python programming language

Use variables to store, retrieve and calculate information

Utilize core programming tools such as functions and loops

There are 7 modules in this course

This course aims to teach everyone the basics of programming computers using Python. We cover the basics of how one constructs a program from a series of simple instructions in Python.  The course has no pre-requisites and avoids all but the simplest mathematics. Anyone with moderate computer experience should be able to master the materials in this course. This course will cover Chapters 1-5 of the textbook “Python for Everybody”.  Once a student completes this course, they will be ready to take more advanced programming courses. This course covers Python 3.

Join - Programming for Everybody (Getting Started with Python)

Python Coding challenge - Day 65 | What is the output of the following Python code?


Code - 

def add(a, b):

    return a + 5 , b + 5


Solution - 

The add function takes two parameters, a and b, and returns a tuple where the first element is the sum of a + 5 and the second element is b + 5.

When you call add(10, 11), it will return a tuple where the first element is 10 + 5 (which is 15) and the second element is 11 + 5 (which is 16). Therefore, the output of print(add(10, 11)) will be: (15, 16)

Thursday 9 November 2023

Computer Vision with Embedded Machine Learning (Free Course)


What you'll learn

How to train and develop an image classification system using machine learning

How to train and develop an object detection system using machine learning

How to deploy a machine learning model to a microcontroller

There are 3 modules in this course

Computer vision (CV) is a fascinating field of study that attempts to automate the process of assigning meaning to digital images or videos. In other words, we are helping computers see and understand the world around us! A number of machine learning (ML) algorithms and techniques can be used to accomplish CV tasks, and as ML becomes faster and more efficient, we can deploy these techniques to embedded systems.

This course, offered by a partnership among Edge Impulse, OpenMV, Seeed Studio, and the TinyML Foundation, will give you an understanding of how deep learning with neural networks can be used to classify images and detect objects in images and videos. You will have the opportunity to deploy these machine learning models to embedded systems, which is known as embedded machine learning or TinyML.

Familiarity with the Python programming language and basic ML concepts (such as neural networks, training, inference, and evaluation) is advised to understand some topics as well as complete the projects. Some math (reading plots, arithmetic, algebra) is also required for quizzes and projects. If you have not done so already, taking the "Introduction to Embedded Machine Learning" course is recommended.

This course covers the concepts and vocabulary necessary to understand how convolutional neural networks (CNNs) operate, and it covers how to use them to classify images and detect objects. The hands-on projects will give you the opportunity to train your own CNNs and deploy them to a microcontroller and/or single board computer. 

Join free - Computer Vision with Embedded Machine Learning

Python Coding challenge - Day 64 | What is the output of the following Python code?



s = set()
s.update('hello', 'how', 'are', 'you?')

Solution - 

The above code counts the total number of unique characters in the given strings. Here's the breakdown:

Create an empty set s:

s = set()

This line initializes an empty set s.

Update the set with multiple string arguments using the update method:

s.update('hello', 'how', 'are', 'you?')

In this line, you're using the update method to add the characters from the strings 'hello', 'how', 'are', and 'you?' to the set s.

Print the length of the set:


This line prints the length (number of elements) of the set s using the len function. Since each character is considered unique, the length will be the total number of unique characters in the combined strings.

The output will be 10 because it counts the total number of unique characters in the provided strings. Thank you for pointing this out.

Wednesday 8 November 2023

Mastering Python for Artificial Intelligence: Learn the Essential Coding Skills to Build Advanced AI Applications (Free PDF)


Are you fascinated by the possibilities of Artificial Intelligence but feel limited by your current coding skills? Do you dream of creating advanced AI applications but need help finding the right resources?

Look no further! "Mastering Python for Artificial Intelligence" is your gateway to learning the essential coding skills that will empower you to build cutting-edge AI applications.

Whether you're a beginner or an experienced programmer, this book will guide you through Python's intricacies and equip you with the knowledge to unleash the true potential of AI.

Mastering Python for Artificial Intelligence" offers an innovative approach encompassing three well-defined principles, ensuring an empowering learning journey for readers.

1. Practicality: The book strongly believes in the value of learning by doing. Unlike many other resources, "Mastering Python for Artificial Intelligence" immediately provides the outputs of ALL the examples. Readers won't have to wait to test the code on their computers or wonder if they are on the right track. This practical approach ensures hands-on experience, reinforcing knowledge and boosting confidence.

2. Simplicity: Learning complex subjects should be approached step by step, and "Mastering Python for Artificial Intelligence" embraces this principle. Each concept is broken down into simple and easily digestible steps. The book aims to make learning efficient and enjoyable, allowing readers to grasp a multitude of topics in the shortest possible time. Clear explanations and examples accompany the content, ensuring rapid progress and understanding.

3. Synthesis: Recognizing that starting with Python can be overwhelming, this book takes a thoughtful approach. Carefully selected topics provide a comprehensive introduction to Python, offering a solid foundation without overwhelming the reader. By presenting essential concepts in a structured manner, the book ensures broad exposure to Python and its applications in Artificial Intelligence.

Here's a sneak peek into what you'll discover:

• Gain a solid understanding of Python's notable features and why it is the preferred language for AI development.

• Learn the step-by-step process of Python IDE installation, ensuring you have the optimal environment for AI programming.

• Explore Python programming fundamentals, including variables, statements, operators, and flow control, laying the groundwork for AI development.

• Dive into the world of data types, such as numeric, sequence, string, list, tuple, set, and dictionary, and understand how they play a crucial role in AI applications.

• Unleash the potential of Python classes and objects and understand how they form the building blocks of AI models and algorithms.

• Discover the wealth of Python libraries and frameworks available for AI development, such as TensorFlow, Keras, scikit-learn, and more.

• Learn how to preprocess data, train AI models, and evaluate their performance using Python's powerful AI libraries.

• Get hands-on experience with practical coding examples and exercises, allowing you to apply your newfound knowledge and solidify your skills.

• The SOLUTIONS to the exercises (but be sure to look at them only after first trying to solve the exercises on your own)

• BONUS: EMPOWERING YOUR LIFE: Harnessing the Power of Chat GPT and Python to Create Your Personal Assistant (scan the QR code inside the book)

Buy - Mastering Python for Artificial Intelligence: Learn the Essential Coding Skills to Build Advanced AI Applications

PDF      -  

Tuesday 7 November 2023

Python Coding challenge - Day 63 | What is the output of the following Python code?


Code - 

l=[1, 0, 2, 0, 'hello', '', []]

print(list(filter(bool, l)))

Solution - 

Step 1: Define a list l with various elements:

l = [1, 0, 2, 0, 'hello', '', []]

This list contains a mix of integers, strings, an empty string, and an empty list.

Step 2: Use the filter() function with bool as the filtering function:

filtered_list = filter(bool, l)

In this step, the filter() function is applied to the list l. The bool function is used as the filtering function. The bool function converts each element of the list into a Boolean value (True or False) based on its truthiness. Elements that evaluate to True are kept, and elements that evaluate to False are removed.

Step 3: Convert the filtered result into a list:

filtered_list = list(filtered_list)

The filter function returns an iterator, so to get the final result as a list, we use the list() constructor to convert the filtered result into a list.

Step 4: Print the filtered list:


This line prints the filtered list to the console.

Step 5: The output is as follows:

[1, 2, 'hello']

In the filtered list, all elements that evaluate to False (0, empty string, and empty list) have been removed. The resulting list contains only the elements that are considered "truthy" according to Python's boolean conversion rules.

SQL for Data Science

What you'll learn

Identify a subset of data needed from a column or set of columns and write a SQL query to limit to those results.

Use SQL commands to filter, sort, and summarize data.

Create an analysis table from multiple queries using the UNION operator.

Manipulate strings, dates, & numeric data using functions to integrate data from different sources into fields with the correct format for analysis.

There are 4 modules in this course

As data collection has increased exponentially, so has the need for people skilled at using and interacting with data; to be able to think critically, and provide insights to make better decisions and optimize their businesses. This is a data scientist, “part mathematician, part computer scientist, and part trend spotter” (SAS Institute, Inc.). According to Glassdoor, being a data scientist is the best job in America; with a median base salary of $110,000 and thousands of job openings at a time. The skills necessary to be a good data scientist include being able to retrieve and work with data, and to do that you need to be well versed in SQL, the standard language for communicating with database systems.

This course is designed to give you a primer in the fundamentals of SQL and working with data so that you can begin analyzing it for data science purposes. You will begin to ask the right questions and come up with good answers to deliver valuable insights for your organization. This course starts with the basics and assumes you do not have any knowledge or skills in SQL. It will build on that foundation and gradually have you write both simple and complex queries to help you select data from tables.  You'll start to work with different types of data like strings and numbers and discuss methods to filter and pare down your results. 

You will create new tables and be able to move data into them. You will learn common operators and how to combine the data. You will use case statements and concepts like data governance and profiling. You will discuss topics on data, and practice using real-world programming assignments. You will interpret the structure, meaning, and relationships in source data and use SQL as a professional to shape your data for targeted analysis purposes. 

Although we do not have any specific prerequisites or software requirements to take this course, a simple text editor is recommended for the final project. So what are you waiting for? This is your first step in landing a job in the best occupation in the US and soon the world!

Join - SQL for Data Science

Python for Everybody Specialization


Learn to Program and Analyze Data with Python. Develop programs to gather, clean, analyze, and visualize data.

Specialization - 5 course series

This Specialization builds on the success of the Python for Everybody course and will introduce fundamental programming concepts including data structures, networked application program interfaces, and databases, using the Python programming language. In the Capstone Project, you’ll use the technologies learned throughout the Specialization to design and create your own  applications for data retrieval, processing, and visualization.

Join - Python for Everybody Specialization

Introduction to Python Programming (Free Course)


Why Python Programming

Welcome to Introduction to Python! Here's an overview of the course.

Data Types and Operators

Familiarize yourself with the building blocks of Python! Learn about data types and operators, built-in functions, type conversion, whitespace, and style guidelines.

Data Structures

Use data structures to order and group different data types together! Learn about the types of data structures in Python, along with more useful built-in functions and operators.

Control Flow

Build logic into your code with control flow tools! Learn about conditional statements, repeating code with loops and useful built-in functions, and list comprehension


Learn how to use functions to improve and reuse your code! Learn about functions, variable scope, documentation, lambda expressions, iterators, and generators.


Setup your own programming environment to write and run Python scripts locally! Learn good scripting practices, interact with different inputs, and discover awesome tools.

Advanced Topics

In this lesson we cover some advanced topics of iterators and generators. You are not required to complete this but we have provided these to give you a taste of these.

Join - Introduction to Python Programming

Monday 6 November 2023

Python Coding challenge - Day 62 | What is the output of the following Python code?


Code - 

def multipliers():
    return [lambda x, i=i: i * x for i in range(4)]
result = [m(2) for m in multipliers()]

Solution -

The code will correctly generate a list of lambda functions that multiply a given value x by the corresponding value of i from the range (0, 1, 2, 3) and then call each of these lambda functions with the argument 2. The correct output will be:

[0, 2, 4, 6]

Here's how it works:

The multipliers function returns a list of lambda functions where each lambda function takes two arguments, x and i. The default argument i=i captures the current value of i from the loop when the lambda function is created.

The list comprehension [m(2) for m in multipliers()] iterates through each lambda function created in the multipliers list and calls it with 2 as the argument. Each lambda function multiplies 2 by its respective i value from the range, resulting in the output [0, 2, 4, 6].

Python for Data Science: The Ultimate Guide for Beginners. Machine Learning Tools, Concepts and Introduction. Python Programming Crash Course


Are you looking for an ultimate python step-by step guide in an efficient way? Do you want to implement a variety of supervised and unsupervised learning algorithms and techniques quickly and accurately?

If you cannot wait to explore the fundamental concepts and entire process on python data science, listen to this audiobook!

You will start by learning the basics of working with Python and the wide variety of data science packages and extensions. You will be guided on how to setup you work environment before diving into the world of data science. In each section you will learn a great deal of theory backed up by practical examples that contain well-explained Python code. Once you have the fundamentals down, you will get to the core of data science learning algorithms and techniques that are industry-standard in this field.

Studying data science and working with supervised and unsupervised algorithms, as well as neural networks, doesn’t have to be as complicated as it sounds. Explore the world of data science using clear, simple, real-world examples and enjoy the power and versatility of Python and machine learning algorithms!

You will explore:

  • How to install Python and setup a scientific distribution.
  • The most popular Python packages and library used in data science and machine learning, such as Scikit-learn, Numpy, Matplotlib, and Pandas.
  • Data munging with pandas and how to import and prepare your dataset for preprocessing and exploration.
  • How to further prepare your data for the data science pipeline by fully understanding concepts such as data exploration, dimensionality reduction, and outlier detection.
  • How to implement supervised and unsupervised machine learning algorithms such as regression algorithms, the Naïve Bayes classifier, K-nearest neighbors, support vector machines, decision trees, and K-means clustering.
  • Neural networks and how to work with feedforward and recurrent networks, with a focus on the restricted Boltzmann machine.
  • Big Data and why it is the path for the future in data science.
  • Even if python for data science is a brand new field to you, this audiobook is the key to introduce you into the python world. Python for Data Science can guide you step-by-step through the entire learning process.

Python Programming for Beginners: An Introduction to the Python Computer Language and Computer Programming


If you want to learn how to program in Python, but don't know where to start read on.

Knowing where to start when learning a new skill can be a challenge, especially when the topic seems so vast. There can be so much information available that you can't even decide where to start. Or worse, you start down the path of learning and quickly discover too many concepts, commands, and nuances that aren't explained. This kind of experience is frustrating and leaves you with more questions than answers.

Python Programming for Beginners doesn't make any assumptions about your background or knowledge of Python or computer programming. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.

Here is what you will learn by listening to Python Programming for Beginners:

  • When to use Python 2 and when to use Python 3.
  • How to install Python on Windows, Mac, and Linux. Screenshots included.
  • How to prepare your computer for programming in Python.
  • The various ways to run a Python program on Windows, Mac, and Linux.
  • Suggested text editors and integrated development environments to use when coding in Python.
  • How to work with various data types including strings, lists, tuples, dictionaries, booleans, and more.
  • What variables are and when to use them.
  • How to perform mathematical operations using Python.
  • How to capture input from a user.
  • Ways to control the flow of your programs.
  • The importance of white space in Python.
  • How to organize your Python programs - Learn what goes where.
  • What modules are, when you should use them, and how to create your own.
  • How to define

Get it - Python Programming for Beginners: An Introduction to the Python Computer Language and Computer Programming

Python - The Bible: 3 Manuscripts in 1 Book: Python Programming for Beginners - Python Programming for Intermediates - Python Programming for Advanced


Python Programming for Beginners - Learn the Basics of Python in 7 Days!

Here's what you'll learn from this book:

  • Introduction 
  • Understanding Python: A Detailed Background 
  • How Python Works 
  • Python Glossary 
  • How to Download and Install Python 
  • Python Programming 101: Interacting with Python in Different Ways 
  • How to Write Your First Python Program 
  • Variables, Strings, Lists, Tuples, Dictionaries 
  • About User-Defined Functions 
  • How to Write User-Defined Functions in Python 
  • About Coding Style 
  • Practice Projects: The Python Projects for Your Practice

Python Programming for Intermediates - Learn the Basics Of Python in 7 Days!

Here's what you'll learn from this book:

  • Shallow Copy and Deep Copy 
  • Objects and Classes in Python - Including Python Inheritance, Multiple Inheritances, and so On
  • Recursion in Python 
  • Debugging and Testing 
  • Fibonacci Sequence (definition) and Monitization in Python 
  • Arguments in Python 
  • Namespaces in Python and Python Modules 
  • Simple Python Projects for Intermediates

Python Programming for Advanced - Learn the Basics of Python in 7 Days!

Here's what you'll learn from this book:

  • File management
  • Python Iterator
  • Python Generator
  • Regular Expressions 
  • Python Closure
  • Python Property
  • Python Assert
  • Simple Recap Projects 
  • Start Coding Now! 

Sunday 5 November 2023

Python Coding challenge - Day 61 | What is the output of the following Python code?


In the above code a tuple named cl that contains a single element, the string 'a'. Tuples are defined by placing a comma-separated sequence of values within parentheses. In this case, you have a single value 'a' enclosed in parentheses.

When you print cl, you will get the following output:


The trailing comma after 'a' is optional but commonly included in tuples with a single element to distinguish them from regular parentheses. It doesn't affect the tuple's behavior but is a convention used to define one-element tuples.

Popular Posts


AI (1) Android (23) AngularJS (1) Assembly Language (2) book (1) Books (35) C (76) C# (12) C++ (82) Course (51) Coursera (8) Cybersecurity (4) Data Science (19) Data Strucures (4) Deep Learning (4) Django (1) Downloads (3) edx (1) Engineering (13) Excel (1) flutter (1) FPL (17) Google (10) Hadoop (1) HTML&CSS (41) IBM (1) IS (25) Java (90) Leet Code (4) Machine Learning (2) Meta (2) Pandas (2) PHP (20) Projects (26) Python (584) Python Coding Challenge (37) R (69) Selenium Webdriver (2) Software (15) SQL (28)


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