Saturday 22 June 2024

Different Ways to Format and Print Characters in Python


Different Ways to Format and Print Characters in Python

1. Using f-strings (Python 3.6+)



2. Using str.format method



3. Using format function with placeholders



4. Using concatenation with chr function

print('[' + chr(65) + ']')


5. Using old-style string formatting

print('[%c]' % 65)


Different Ways to Format and Print Hexadecimal Values in Python


Different Ways to Format and Print Hexadecimal Values in Python

1. Using f-strings (Python 3.6+)

print(f'{15:x}, {15:X}')

f, F

2. Using str.format method

print('{}, {}'.format(format(15, 'x'), format(15, 'X')))

f, F

3. Using format function with placeholders

print('{:x}, {:X}'.format(15, 15))

f, F

4. Using hex function and string slicing

print('{}, {}'.format(hex(15)[2:], hex(15)[2:].upper()))

f, F

5. Using old-style string formatting

print('%x, %X' % (15, 15))

f, F

Different Ways to Print Binary Values as Decimals in Python


Different Ways to Print Binary Values as Decimals in Python
1. Directly using the binary literal
2. Using int function with a binary string
print(int('101', 2))
3. Using format function for binary to decimal conversion
print(int(format(0b101, 'd')))
4. Using f-strings (Python 3.6+)
binary_value = 0b101
5. Using str.format method
binary_value = 0b101

Friday 21 June 2024

Matrix in Python


Rank of Matrix
import numpy as np

x = np.matrix("4,5,16,7;2,-3,2,3;,3,4,5,6;4,7,8,9")
[[ 4  5 16  7]
 [ 2 -3  2  3]
 [ 3  4  5  6]
 [ 4  7  8  9]]
#numpy.linalg.matrix_rank() - return a rank of a matrix
# Syntax: numpy.linalg.matrix_rank(matrix)
rank_matrix = np.linalg.matrix_rank(x)
Determinant of Matrix
import numpy as np

x = np.matrix("4,5,16,7;2,-3,2,3;,3,4,5,6;4,7,8,9")
[[ 4  5 16  7]
 [ 2 -3  2  3]
 [ 3  4  5  6]
 [ 4  7  8  9]]
det_matrix = np.linalg.det(x)
Inverse of a Matrix
inverse formula = A-1 = (1/determinant of A) * adj A

numpy.linalg.inv() - return the multiplicative inverse of a matrix Syntax: numpy.linalg.inv(matrix)

A = np.matrix("3,1,2;3,2,5;6,7,8")
[[3 1 2]
 [3 2 5]
 [6 7 8]]
Inv_matrix = np.linalg.inv(A)
[[ 0.57575758 -0.18181818 -0.03030303]
 [-0.18181818 -0.36363636  0.27272727]
 [-0.27272727  0.45454545 -0.09090909]]

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



list1 = [1]

list_iter = iter(list1)



Let's break down the code and its behavior step by step:

  1. Creating the List:

    list1 = [1]

    This line creates a list named list1 containing a single element, the integer 1.

  2. Creating the Iterator:

    list_iter = iter(list1)

    This line creates an iterator object from the list list1. The iter() function is used to create an iterator, which is an object that allows you to traverse through all the elements of a collection (such as a list) one by one.

  3. Accessing the Next Element:


    The next() function is used to retrieve the next item from the iterator list_iter. In this case, since the list list1 contains only one element, calling next(list_iter) will return the first and only element, which is 1.

Here is what happens in detail:

  • When list_iter = iter(list1) is executed, an iterator object is created that will traverse the list list1.
  • The first call to next(list_iter) retrieves the first element of list1, which is 1.
  • The print() function then outputs this value to the console.

Putting it all together, the code:

list1 = [1] list_iter = iter(list1)

will output:


This is because the iterator retrieves the first element from the list and print() prints it. If you were to call next(list_iter) again without adding more elements to the list or resetting the iterator, you would get a StopIteration exception since there are no more elements left in the iterator.

Introduction to Network Automation


Build your subject-matter expertise

This course is part of the Network Automation Engineering Fundamentals 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: Introduction to Network Automation

There are 3 modules in this course

The Network infrastructure industry has undergone a significant transformation in recent years, with an increasing need for automation due to factors such as a demand for faster and more reliable network deployments. Therefore, there is a growing need for network engineers skilled in automation and programmability.

This course is primarily intended for network engineers, systems engineers, network architects, and managers interested in learning the fundamentals of network automation.

By the end of the course, you will be able to:

- Articulate the role network automation and programmability plays in the context of end-to-end network management and operations.

- Interpret Python scripts with fundamental programming constructs built for network automation use cases.

To be successful in this course, you should be proficient in fundamental network routing & switching technologies, understand the basics of Python programming (3-6 mos exp.), and have some familiarity with Linux.

Network Automation Engineering Fundamentals Specialization


What you'll learn

The issues network automation can solve, building a foundation for further mastery

The basics of NETCONF, RESTCONF, gNMI, and YANG modeling

How to script security topics with Ansible and Python

Join Free: Network Automation Engineering Fundamentals Specialization

Specialization - 5 course series

The Network Automation Engineering Fundamentals Specialization takes mid- to expert-level network engineers through the primary topics of network automation and programmability and prepares them for the NetDevOps environment. This Specialization serves as a well-rounded survey of topics and core skills that a network automation engineer should know to effectively deploy and operate a NetDevOps environment.

Completing this Specialization will help you prepare to operate as a network automation engineer with the skills needed to advance your career.

Applied Learning Project

We do not have any hands-on projects in this specialization curriculum. 

On Completion of this Specialization, you will be prepared to operate as a network automation engineer with the necessary skills needed to advance in your career. This Specialization serves as a well-rounded survey of topics and core skills that a network automation engineer should know to effectively deploy and operate a NetDevOps environment.

Wednesday 19 June 2024

Tuesday 18 June 2024

Mastering PyTorch - Second Edition: Create and deploy deep learning models from CNNs to multimodal models, LLMs, and beyond


Master advanced techniques and algorithms for machine learning with PyTorch using real-world examples

Updated for PyTorch 2.x, including integration with Hugging Face, mobile deployment, diffusion models, and graph neural networks

Purchase of the print or Kindle book includes a free eBook in PDF format

Key Features:

- Understand how to use PyTorch to build advanced neural network models

- Get the best from PyTorch by working with Hugging Face, fastai, PyTorch Lightning, PyTorch Geometric, Flask, and Docker

- Unlock faster training with multiple GPUs and optimize model deployment using efficient inference frameworks

Book Description:

PyTorch is making it easier than ever before for anyone to build deep learning applications. This PyTorch deep learning book will help you uncover expert techniques to get the most from your data and build complex neural network models.

You'll build convolutional neural networks for image classification and recurrent neural networks and transformers for sentiment analysis. As you advance, you'll apply deep learning across different domains, such as music, text, and image generation using generative models, including diffusion models. You'll not only build and train your own deep reinforcement learning models in PyTorch but also learn to optimize model training using multiple CPUs, GPUs, and mixed-precision training. You'll deploy PyTorch models to production, including mobile devices. Finally, you'll discover the PyTorch ecosystem and its rich set of libraries. These libraries will add another set of tools to your deep learning toolbelt, teaching you how to use fastai for prototyping models to training models using PyTorch Lightning. You'll discover libraries for AutoML and explainable AI (XAI), create recommendation systems, and build language and vision transformers with Hugging Face.

By the end of this book, you'll be able to perform complex deep learning tasks using PyTorch to build smart artificial intelligence models.

What You Will Learn:

- Implement text, vision, and music generating models using PyTorch

- Build a deep Q-network (DQN) model in PyTorch

- Deploy PyTorch models on mobile devices (Android and iOS)

- Become well-versed with rapid prototyping using PyTorch with

- Perform neural architecture search effectively using AutoML

- Easily interpret machine learning models using Captum

- Design ResNets, LSTMs, and graph neural networks (GNNs)

- Create language and vision transformer models using Hugging Face

Who this book is for:

This deep learning with PyTorch book is for data scientists, machine learning engineers, machine learning researchers, and deep learning practitioners looking to implement advanced deep learning models using PyTorch. This book is ideal for those looking to switch from TensorFlow to PyTorch. Working knowledge of deep learning with Python is required.

Hard Copy: Mastering PyTorch: Create and deploy deep learning models from CNNs to multimodal models, LLMs, and beyond

Sunday 16 June 2024

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



s = "immutable"

s[1] = 'n'


Solution and Explanation:

The code snippet you provided is attempting to demonstrate a fundamental property of Python strings: their immutability.

Let's break it down step by step:

Assigning the String:

s = "immutable"

Here, we assign the string "immutable" to the variable s. Strings in Python are sequences of characters and are immutable, meaning once a string is created, its content cannot be changed.

Attempting to Modify the String:

s[1] = 'n'

This line tries to change the character at index 1 of the string s from 'm' to 'n'. However, because strings are immutable, this operation is not allowed in Python. Attempting to assign a new value to a specific index of a string will raise a TypeError.

Printing the String:


This line prints the current value of s. However, because the previous line raises an error, this line will not be executed unless the error is handled.

Let's see what happens if we run this code:

s = "immutable"

s[1] = 'n'  # This line will raise an error

print(s)  # This line will not be executed because of the error above

When you run this code, Python will raise an error at the line s[1] = 'n', and the error message will be something like this:

TypeError: 'str' object does not support item assignment

This error message indicates that you cannot assign a new value to an individual index in a string because strings do not support item assignment.

If you need to modify a string, you must create a new string. For example, if you want to change the second character of s to 'n', you can do it by creating a new string:

s = "immutable"

s = s[:1] + 'n' + s[2:]


This code will correctly print innutable, as it constructs a new string by concatenating parts of the original string with the new character.

Friday 14 June 2024

Machine Learning with Python: From Beginner to Advanced course syllabus


Module 1: Introduction to Machine Learning

  • Week 1: Overview of Machine Learning

    • What is Machine Learning?
    • Types of Machine Learning: Supervised, Unsupervised, Reinforcement
    • Real-world applications of Machine Learning
    • Setting up Python environment: Anaconda, Jupyter Notebooks, essential libraries (NumPy, pandas, matplotlib, scikit-learn)
  • Week 2: Python for Data Science

    • Python basics: Data types, control flow, functions
    • NumPy for numerical computing
    • pandas for data manipulation
    • Data visualization with matplotlib and seaborn

Module 2: Supervised Learning

  • Week 3: Regression

    • Introduction to regression analysis
    • Simple Linear Regression
    • Multiple Linear Regression
    • Evaluation metrics: Mean Squared Error, R-squared
  • Week 4: Classification

    • Introduction to classification
    • Logistic Regression
    • K-Nearest Neighbors (KNN)
    • Evaluation metrics: Accuracy, Precision, Recall, F1 Score, ROC-AUC
  • Week 5: Advanced Supervised Learning Algorithms

    • Decision Trees
    • Random Forests
    • Gradient Boosting Machines (XGBoost)
    • Support Vector Machines (SVM)

Module 3: Unsupervised Learning

  • Week 6: Clustering

    • Introduction to clustering
    • K-Means Clustering
    • Hierarchical Clustering
    • DBSCAN
  • Week 7: Dimensionality Reduction

    • Introduction to dimensionality reduction
    • Principal Component Analysis (PCA)
    • t-Distributed Stochastic Neighbor Embedding (t-SNE)
    • Singular Value Decomposition (SVD)

Module 4: Reinforcement Learning

  • Week 8: Fundamentals of Reinforcement Learning

    • Introduction to Reinforcement Learning
    • Key concepts: Agents, Environments, Rewards
    • Markov Decision Processes (MDP)
    • Q-Learning
  • Week 9: Deep Reinforcement Learning

    • Deep Q-Networks (DQN)
    • Policy Gradient Methods
    • Applications of Reinforcement Learning

Module 5: Deep Learning

  • Week 10: Introduction to Neural Networks

    • Basics of Neural Networks
    • Activation Functions
    • Training Neural Networks: Forward and Backward Propagation
  • Week 11: Convolutional Neural Networks (CNNs)

    • Introduction to CNNs
    • CNN architectures: LeNet, AlexNet, VGG, ResNet
    • Applications in Image Recognition
  • Week 12: Recurrent Neural Networks (RNNs)

    • Introduction to RNNs
    • Long Short-Term Memory (LSTM) networks
    • Applications in Sequence Prediction

Module 6: Advanced Topics

  • Week 13: Natural Language Processing (NLP)

    • Introduction to NLP
    • Text Preprocessing
    • Sentiment Analysis
    • Topic Modeling
  • Week 14: Model Deployment and Production

    • Saving and loading models
    • Introduction to Flask for API creation
    • Deployment on cloud platforms (AWS, Google Cloud, Heroku)
  • Week 15: Capstone Project

    • Work on a real-world project
    • End-to-end model development: Data collection, preprocessing, model training, evaluation, and deployment
    • Presentation and review

Wednesday 12 June 2024

Data Science Basics to Advance Course Syllabus


Week 1: Introduction to Data Science and Python Programming

  • Overview of Data Science
    • Understanding what data science is and its importance.
  • Python Basics
    • Introduction to Python, installation, setting up the development environment.
  • Basic Python Syntax
    • Variables, data types, operators, expressions.
  • Control Flow
    • Conditional statements, loops.
  • Functions and Modules
    • Defining, calling, and importing functions and modules.
  • Hands-on Exercises
    • Basic Python programs and assignments.

Week 2: Data Structures and File Handling in Python

  • Data Structures
    • Lists, tuples, dictionaries, sets.
  • Manipulating Data Structures
    • Indexing, slicing, operations.
  • File Handling
    • Reading from and writing to files, file operations.
  • Error Handling
    • Using try-except blocks.
  • Practice Problems
    • Mini-projects involving data structures and file handling.

Week 3: Data Wrangling with Pandas

  • Introduction to Pandas
    • Series and DataFrame objects.
  • Data Manipulation
    • Indexing, selecting data, filtering.
  • Data Cleaning
    • Handling missing values, data transformations.
  • Data Integration
    • Merging, joining, concatenating DataFrames.
  • Hands-on Exercises
    • Data wrangling with real datasets.

Week 4: Data Visualization

  • Introduction to Matplotlib
    • Basic plotting, customization.
  • Advanced Visualization with Seaborn
    • Statistical plots, customization.
  • Interactive Visualization with Plotly
    • Creating interactive plots.
  • Data Visualization Projects
    • Creating visualizations for real datasets.

Week 5: Exploratory Data Analysis (EDA) - Part 1

  • Importance of EDA
    • Understanding data and deriving insights.
  • Descriptive Statistics
    • Summary statistics, data distributions.
  • Visualization for EDA
    • Histograms, box plots.
  • Correlation Analysis
    • Finding relationships between variables.
  • Hands-on Projects
    • Conducting EDA on real-world datasets.

Week 6: Exploratory Data Analysis (EDA) - Part 2

  • Visualization for EDA
    • Scatter plots, pair plots.
  • Handling Missing Values and Outliers
    • Techniques for dealing with incomplete data.
  • Feature Engineering
    • Creating new features, transforming existing features.
  • Hands-on Projects
    • Advanced EDA techniques on real datasets.

Week 7: Data Collection and Preprocessing Techniques

  • Data Collection Methods
    • Surveys, web scraping, APIs.
  • Data Cleaning
    • Handling missing data, outliers, and inconsistencies.
  • Data Transformation
    • Normalization, standardization, encoding categorical variables.
  • Hands-on Projects
    • Collecting and preprocessing real-world data.

Week 8: Database Management and SQL

  • Introduction to Databases
    • Relational databases, database design.
  • SQL Basics
    • SELECT, INSERT, UPDATE, DELETE statements.
  • Advanced SQL
    • Joins, subqueries, window functions.
  • Connecting Python to Databases
    • Using libraries like SQLAlchemy.
  • Hands-on Exercises
    • SQL queries and database management projects.

Week 9: Introduction to Time Series Analysis

  • Time Series Concepts
    • Understanding time series data, components of time series.
  • Time Series Visualization
    • Plotting time series data, identifying patterns.
  • Basic Time Series Analysis
    • Moving averages, smoothing techniques.
  • Hands-on Exercises
    • Working with time series data.

Week 10: Advanced Time Series Analysis

  • Decomposition
    • Breaking down time series into trend, seasonality, and residuals.
  • Forecasting Methods
    • Introduction to ARIMA and other forecasting models.
  • Model Evaluation
    • Assessing forecast accuracy.
  • Practical Application
    • Time series forecasting projects.

Week 11: Advanced Data Wrangling with Pandas

  • Advanced Data Manipulation
    • Pivot tables, groupby operations.
  • Time Series Manipulation
    • Working with date and time data in Pandas.
  • Merging and Joining DataFrames
    • Advanced techniques for combining datasets.
  • Practical Exercises
    • Complex data wrangling tasks.

Week 12: Advanced Data Visualization Techniques

  • Interactive Dashboards
    • Creating dashboards with Dash and Tableau.
  • Geospatial Data Visualization
    • Mapping data with libraries like Folium.
  • Storytelling with Data
    • Effective communication of data insights.
  • Practical Projects
    • Building interactive and compelling data visualizations.

Tuesday 11 June 2024

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



x = "123"

y = int(x)

z = str(y)

print(x is z)

Solution and Explanation:

Let's break down the code step by step to understand what's happening and why print(x is z) will produce a specific result.

Assignment: x = "123"

Here, x is assigned the string value "123".

Conversion to Integer: y = int(x)

This line converts the string x to an integer. So, y becomes the integer 123.

Conversion back to String: z = str(y)

This line converts the integer y back to a string. So, z becomes the string "123".

Identity Check: print(x is z)

The is operator checks if x and z refer to the same object in memory.

Even though x and z both contain the string "123", they are two distinct objects. In Python, is checks for object identity, not equality. This means it checks whether both variables point to the exact same object in memory.

Here's a more detailed look:

After x = "123", x points to a string object "123" in memory.

After y = int(x), y points to an integer object 123 in memory.

After z = str(y), z points to a new string object "123" in memory. This new string object has the same value as x but is a different object.

Therefore, when you execute print(x is z), it will print False because x and z are not the same object in memory.

Therefore, when you execute print(x is z), it will print False because x and z are not the same object in memory.

To summarize:

x == z would be True because the contents of the strings are the same.

x is z is False because x and z are different objects in memory.

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


Let's break down the given code step by step:

a = 0

a = not not a


Initialization: a = 0

Here, a is assigned the value 0, which in Python is considered False when used in a boolean context.

Double Negation: a = not not a

First Negation: not a

not is a logical operator that inverts the boolean value of its operand.
Since a is 0 (which is False in a boolean context), not a evaluates to True.
Second Negation: not (not a)

Now, we apply the not operator again to the result of the first negation.
not True evaluates to False.
So, a = not not a effectively assigns False to a.

Print the Result: print(a)

The value of a is now False, so the print(a) statement will output: False 
In this code:

a starts with the value 0.
Applying not not to a converts it to a boolean and then applies double negation.
Since 0 is False, not not a evaluates to False.
Therefore, print(a) outputs False.

Sunday 9 June 2024

Stacks and Queues in Python: A Beginner's Guide


In the world of data structures, stacks and queues are fundamental concepts that every programmer should understand. These data structures are essential for managing data in a specific order, and they find applications in various algorithms and real-world scenarios. In this blog, we will explore what stacks and queues are, how to implement them in Python, and provide some examples to demonstrate their usage.

What is a Stack?

A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. This means that the last element added to the stack is the first one to be removed. Think of a stack of plates: you can only take the top plate off the stack, and when you add a plate, you place it on the top.

Common operations on a stack include:

  • Push: Add an item to the top of the stack.
  • Pop: Remove the item from the top of the stack.
  • Peek: Get the item from the top of the stack without removing it.
  • IsEmpty: Check if the stack is empty.
  • Size: Get the number of items in the stack.

Here’s a simple implementation of a stack 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 self.is_empty():

            raise IndexError("pop from empty stack")

        return self.items.pop()

    def peek(self):

        if self.is_empty():

            raise IndexError("peek from empty stack")

        return self.items[-1]

    def size(self):

        return len(self.items)

    def __str__(self):

        return str(self.items)

Example Usage:

stack = Stack()
print("Stack after pushing 1, 2, 3:", stack)

print("Popped item:", stack.pop())
print("Stack after popping:", stack)

print("Top item:", stack.peek())
print("Stack size:", stack.size())

What is a Queue?

A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. This means that the first element added to the queue is the first one to be removed. Think of a queue of people waiting in line: the person who gets in line first is the first one to be served.

Common operations on a queue include:

  • Enqueue: Add an item to the end of the queue.
  • Dequeue: Remove the item from the front of the queue.
  • IsEmpty: Check if the queue is empty.
  • Size: Get the number of items in the queue.

Here’s a simple implementation of a queue 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 self.is_empty():

            raise IndexError("dequeue from empty queue")

        return self.items.pop(0)

    def size(self):

        return len(self.items)

    def __str__(self):

        return str(self.items)

Example Usage:

queue = Queue()
print("Queue after enqueueing 1, 2, 3:", queue)

print("Dequeued item:", queue.dequeue())
print("Queue after dequeuing:", queue)

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

Stack Operations Example

Let’s delve into a few operations to understand how a stack works: 

# Push elements




print("Stack:", stack)  # Output: [10, 20, 30]

# Pop element

print("Popped element:", stack.pop())  # Output: 30

print("Stack after pop:", stack)  # Output: [10, 20]

# Peek element

print("Top element:", stack.peek())  # Output: 20

# Stack size

print("Stack size:", stack.size())  # Output: 2

Queue Operations Example

Similarly, let’s look at a few operations to see how a queue works:

# Enqueue elements




print("Queue:", queue)  # Output: [10, 20, 30]

# Dequeue element

print("Dequeued element:", queue.dequeue())  # Output: 10

print("Queue after dequeue:", queue)  # Output: [20, 30]

# Queue size

print("Queue size:", queue.size())  # Output: 2


Stacks and queues are essential data structures that provide a way to store and manage data efficiently. By understanding and implementing these structures, you can solve various computational problems more effectively. In this blog, we explored the basic concepts of stacks and queues, implemented them in Python, and demonstrated their usage with simple examples. Whether you are a beginner or an experienced programmer, mastering these data structures is crucial for your programming toolkit.

Saturday 8 June 2024

Python Programming Course Syllabus

Week 1: Introduction to Coding and Python

  • Topic: Introduction to coding and Python.
  • Details:
    • Overview of programming concepts and Python's significance.
    • Installing Python and setting up the development environment.
    • Introduction to Integrated Development Environments (IDEs) like PyCharm, VS Code, or Jupyter Notebooks.

Week 2: Variables and Data Types

  • Topic: Understanding variables and data types.
  • Details:
    • Variables: Naming conventions and assignment.
    • Data types: strings, integers, floats, and booleans.
    • Simple calculations and printing output.

Week 3: User Interaction

  • Topic: Using the input() function for user interaction.
  • Details:
    • Reading user input.
    • Converting input types.
    • Using input in simple programs.

Week 4: Decision Making with If-Else Statements

  • Topic: Basic if-else statements for decision-making.
  • Details:
    • Syntax and structure of if, elif, and else.
    • Nested if-else statements.
    • Practical examples and exercises.

Week 5: Introduction to Loops

  • Topic: Introduction to loops for repetitive tasks.
  • Details:
    • While loops: syntax and use cases.
    • For loops: syntax and use cases.
    • Loop control statements: break, continue, and pass.
    • Simple loop exercises.

Week 6: Functions and Code Organization

  • Topic: Introduction to functions.
  • Details:
    • Definition and syntax of functions.
    • Parameters and return values.
    • The importance of functions in organizing code.

Week 7: Built-in and User-Defined Functions

  • Topic: Exploring built-in functions and creating user-defined functions.
  • Details:
    • Common built-in functions in Python.
    • Creating and using user-defined functions.
    • Scope and lifetime of variables.

Week 8: Working with Lists

  • Topic: Understanding and using lists.
  • Details:
    • Creating and modifying lists.
    • List indexing and slicing.
    • Common list operations (append, remove, pop, etc.).
    • List comprehensions.

Week 9: String Manipulation

  • Topic: Introduction to string manipulation.
  • Details:
    • String slicing and indexing.
    • String concatenation and formatting.
    • Common string methods (split, join, replace, etc.).

Week 10: Recap and Practice

  • Topic: Recap and practice exercises.
  • Details:
    • Review of previous topics.
    • Practice exercises and mini-projects.
    • Q&A session for clarification of doubts.

Week 11: Introduction to Dictionaries

  • Topic: Working with dictionaries for key-value data storage.
  • Details:
    • Creating and accessing dictionaries.
    • Dictionary methods and operations (keys, values, items, etc.).
    • Practical examples and exercises.

Week 12: Working with Files

  • Topic: Reading and writing data to files.
  • Details:
    • File handling modes (read, write, append).
    • Reading from and writing to files.
    • Practical file handling exercises.

Week 13: Exceptions and Error Handling

  • Topic: Introduction to exceptions and error handling.
  • Details:
    • Understanding exceptions.
    • Try, except, else, and finally blocks.
    • Raising exceptions.
    • Practical error handling exercises.

Week 14: Introduction to Object-Oriented Programming

  • Topic: Basic introduction to object-oriented programming.
  • Details:
    • Understanding classes and objects.
    • Creating classes and objects.
    • Attributes and methods.
    • Practical examples of OOP concepts.

Week 15: Final Recap and Practice

  • Topic: Recap and practice exercises.
  • Details:
    • Comprehensive review of all topics.
    • Advanced practice exercises and projects.
    • Final Q&A and course completion.




File Chooser using Python


from plyer import filechooser

# Open a file chooser dialog

file_path = filechooser.open_file()

print("Selected file:", file_path)

# Open multiple files chooser dialog

files_path = filechooser.open_file(multiple=True)

print("Selected files:", files_path)

# Save file chooser dialog

save_path = filechooser.save_file()

print("Save file path:", save_path)

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


Let's break down the code step by step:

cl = 4
while cl < 6:
    cl = cl + 1     print(cl, end='-')


  1. Initialization:

    cl = 4

    Here, the variable cl is initialized to 4.

  2. While Loop Condition:

    while cl < 6:   
  3.  The while loop will continue to execute as long as the condition cl < 6 is True. Initially, cl is 4, so the condition is True.
  4. Inside the Loop:

    cl = cl + 1

    Inside the loop, cl is incremented by 1. The first time this statement is executed, cl becomes 5.
  5. Print Statement:

    print(cl, end='-')

    This prints the current value of cl followed by a hyphen -. The end='-' part ensures that the next output is printed immediately after the hyphen without moving to a new line.

Step-by-Step Execution

  • Initial State:

    cl is 4.
    The while condition cl < 6 is checked and is True.
  • First Iteration:

    cl = cl + 1 is executed, so cl becomes 5.
    print(cl, end='-') prints 5-.
  • Second Iteration:

      The while condition cl < 6 is checked again. Now cl is 5, so the condition is still = cl + 1 is executed again, so cl becomes 6.
      print(cl, end='-') prints 6-.
  • End of Loop:

    The while condition cl < 6 is checked once more. Now cl is 6, so the condition is False.
    The loop terminates.


The output of this code will be:


Each iteration of the loop increases the value of cl by 1 and prints it, followed by a hyphen. The loop stops running when cl reaches 6.

Friday 7 June 2024

Python Programming Basics: For Freshers Learn Python Programming Infrastructure and Attend Interviews free pdf


Python Programming Basics

For Freshers Learn Python Programming Infrastructure and Attend Interviews

What You Will Learn

Chapter 1 : Basics

1 Python Introduction

2 Python Variables

Chapter 2 : Data Types

1 Python boolean

2 Python String

3 Python Number

4 Python List

5 Python Tuple

6 Python Dictionary

Chapter 3 : Operators

1 Python Arithmetic Operators

2 Python Bitwise Operators

3 Python Comparison Operators

4 Python Logical Operators

5 Python Ternary Operators

Chapter 4 : Statements

1 Python if

2 Python while

3 Python for loop

4 Python pass

5 Python break

6 Python continue

Chapter 5 : Functions

1 Python function

2 Python Function Recursion

Chapter 6 : Object Oriented

1 Python Modules

2 Python class

3 Python class Inheritance

4 Python Abstract Base Classes

5 Python Operator Overloading

Chapter 7 : Advanced

1 Python File

2 Python Text File

3 Python Exceptions

4 Python Testing

Free PDF: Python Programming Basics: For Freshers Learn Python Programming Infrastructure and Attend Interviews

Hard Copy: Python Programming Basics: For Freshers Learn Python Programming Infrastructure and Attend Interviews

Monday 3 June 2024

Country Details using Python


from countryinfo import CountryInfo

country = CountryInfo(input("Enter Country Name:"))

# Various information about the country

print("Country Name:",


print("Population:", country.population())

print("Area (in square kilometers):", country.area())

print("Region:", country.region())

print("Subregion:", country.subregion())

print("Demonym:", country.demonym())

print("Currency:", country.currencies())

print("Languages:", country.languages())

print("Borders: ", country.borders())

Sunday 2 June 2024

Print Calendar using Python


Let's break down the code and understand what it does step by step.

Code Explanation

Importing the Calendar Module:

from calendar import *

  • This line imports all the functions and classes from the calendar module in Python. The calendar module provides various functions related to calendar operations.

Getting User Input:

year = int(input('Enter Year:'))
  • This line prompts the user to enter a year. The input function takes the user's input as a string, and the int function converts this string to an integer, which is then stored in the variable year.

Printing the Calendar:

print(calendar(year, 2, 1, 8, 4))
  • This line is intended to print the calendar for the given year with specific formatting. 
formatyear(year, w=2, l=1, c=6, m=3):
  • year: The year for which the calendar is to be printed.
  • w: The width of each date column (default is 2).
  • l: The number of lines for each week (default is 1).
  • c: The number of spaces between month columns (default is 6).
  • m: The number of months per row (default is 3).

Popular Posts


AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (120) C (77) C# (12) C++ (82) Course (64) Coursera (182) Cybersecurity (24) data management (11) Data Science (98) Data Strucures (6) Deep Learning (10) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Pandas (3) PHP (20) Projects (29) Python (772) Python Coding Challenge (256) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)


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