Python coding
53 subscribers
24 files
11 links
​A technical hub dedicated to Python programming, web development, and software engineering. Learn core syntax, build full-stack projects, and master backend development.
Download Telegram
Python coding
Basic_Python_CSV_JSON_Handling.pdf
Basic Python Course
Data Analysis with Pandas

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

1. Introduction to Pandas

Pandas is one of the most powerful and popular Python libraries for data analysis.

It helps programmers:
- Analyze data
- Clean messy datasets
- Organize information
- Discover patterns

Pandas is built on top of NumPy, making it fast and efficient.

---

Why Use Pandas?

Data Cleaning:
Fix missing or incorrect values.

Data Exploration:
Understand what exists inside your dataset.

Speed:
Handles large files efficiently.

Real-World Usage:
Used heavily in:
- Data Science
- Artificial Intelligence
- Business Analytics
- Machine Learning

---

2. Importing Pandas

Before using Pandas:

import pandas as pd

`pd` is simply a short alias for Pandas.

---

3. Creating a DataFrame

A DataFrame is like a spreadsheet or table.

Example:

import pandas as pd

data = {
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}

df = pd.DataFrame(data)

print(df)

Output:

   calories  duration
0 420 50
1 380 40
2 390 45

---

4. Series vs DataFrame

Pandas mainly uses two structures.

---

Series

A one-dimensional structure.

Example:

series = pd.Series([1, 2, 3])

print(series)

---

DataFrame

A multi-dimensional table.

Example:

df = pd.DataFrame(data)

Think of:
- Series → One column
- DataFrame → Entire spreadsheet

---

5. Reading CSV Files

CSV stands for Comma Separated Values.

Most real-world datasets are stored as CSV files.

Example:

df = pd.read_csv("data.csv")

print(df.to_string())

---

Useful Tip

By default, Pandas only shows part of large datasets.

Increase visible rows:

pd.options.display.max_rows = 9999

---

6. Inspecting Data

---

head()

Shows the first rows.

print(df.head())

---

tail()

Shows the last rows.

print(df.tail())

---

info()

Displays important dataset information.

print(df.info())

This shows:
- Column names
- Data types
- Non-null values
- Memory usage

---

What Does "Non-Null" Mean?

Non-null means:
A cell contains actual data and is NOT empty.

Example:

Age
21
18
NULL
25

Only 3 rows are non-null.

---

7. Introduction to Data Cleaning

Real-world datasets are often messy.

Pandas provides tools to clean them.

---

Removing Empty Rows

new_df = df.dropna()

This removes rows with missing values.

---

Replacing Missing Values

df.fillna(130, inplace=True)

This replaces empty cells with 130.

---

Checking Duplicates

print(df.duplicated())

Returns:
- True → Duplicate row
- False → Unique row

---

8. Why Pandas is Important

Pandas is heavily used in:
- AI
- Machine Learning
- Financial Analysis
- Data Visualization
- Scientific Research

Almost every data scientist uses Pandas daily.

---

Practice Exercises

1. Load and Inspect

Load data.csv and print the last 10 rows.

---

2. Data Summary

Use .info() and explain what "Non-Null" means.

---

3. Dictionary to DataFrame

Create a dictionary of 5 students and their grades, then convert it into a DataFrame.
Python coding
Basic_Python_Matplotlib_Visualization.pdf
Basic Python Course
Data Visualization with Matplotlib

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

1. Introduction to Matplotlib

Matplotlib is one of the most popular Python libraries for data visualization.

It helps transform raw numbers into:
- Charts
- Graphs
- Visual insights

Most plotting features are available inside the pyplot module.

---

Importing Matplotlib

import matplotlib.pyplot as plt
import numpy as np

---

2. Basic Line Plot

A line plot connects data points using lines.

Example:

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.array([0, 6])
ypoints = np.array([0, 250])

plt.plot(xpoints, ypoints)

plt.show()

---

What plt.show() Does

plt.show() displays the graph window.

Without it, the graph may not appear.

---

3. Markers and Line Styles

Markers highlight data points.

Common markers:

| Marker | Meaning |
|--------|----------|
| 'o' | Circle |
| '*' | Star |
| '.' | Point |

---

Example with Marker and Style

ypoints = np.array([3, 8, 1, 10])

plt.plot(
ypoints,
marker='*',
linestyle='dotted',
color='r'
)

plt.show()

---

Understanding the Parameters

- marker='*' → Star marker
- linestyle='dotted' → Dotted line
- color='r' → Red color

---

4. Labels and Titles

Graphs become meaningful when labels are added.

---

Example

x = np.array([80, 85, 90, 95])
y = np.array([240, 250, 260, 270])

plt.plot(x, y)

plt.title("Sports Watch Data")
plt.xlabel("Average Pulse")
plt.ylabel("Calorie Burnage")

plt.grid()

plt.show()

---

Why Grids Matter

Grids make charts easier to read and compare.

---

5. Plotting Multiple Lines

Matplotlib allows multiple datasets on one graph.

Example:

y1 = np.array([3, 8, 1, 10])
y2 = np.array([6, 2, 7, 11])

plt.plot(y1, label='Dataset A')
plt.plot(y2, label='Dataset B')

plt.legend()

plt.show()

---

What legend() Does

plt.legend() shows labels for each line.

Useful when comparing datasets.

---

6. Visualizing CSV Data

Matplotlib works perfectly with Pandas DataFrames.

Example:

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('data4.csv')

df.plot(
kind='scatter',
x='Pulse',
y='Calories'
)

plt.title("Relationship between Pulse and Calories")

plt.show()

---

What is a Scatter Plot?

A scatter plot displays relationships between two variables.

Useful for:
- Trend analysis
- Data patterns
- Correlation discovery

---

7. Why Visualization Matters

Humans understand visuals faster than raw numbers.

Visualization helps:
- Discover patterns
- Detect mistakes
- Compare data
- Explain results clearly

---

Real-World Uses of Matplotlib

- Data Science
- AI & Machine Learning
- Business Analytics
- Financial Charts
- Scientific Research

---

Practice Exercises

1. The Star Plot

Create a line plot for:

[2, 10, 4, 8]

Use:
- Red star markers
- Dashed line

---

2. Grid Challenge

Recreate the "Sports Watch" graph and add a grid only on the Y-axis.

Hint:

plt.grid(axis='y')

---

3. Data Insight

Load data4.csv and create a line plot showing how "Maxpulse" changes over time.
Hello everyone! 👋

​You might have noticed a temporary pause in our regular posts recently. I wanted to let you all know that I have paused posting in celebration of Eid.

​Regular educational content and updates will resume right after the holiday! Enjoy the break, take some time to review the previous material, and get ready for more exciting programming and development content coming your way very soon.

​Thank you for your understanding, and see you all after Eid! ✨

Eid Mubarek ✨✨
👍1
Python coding
sales.csv
Basic Python Course
Matplotlib Visualization Lab

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

Introduction

Visualization helps transform raw numbers into meaningful insights.

In this lab, we will create charts using Matplotlib and NumPy to understand patterns, trends, and comparisons.

---

Exercise 1: Plotting a Linear Function

A linear function has the general form:

y = mx + b

Where:
- m = slope
- b = y-intercept

For this exercise:

y = 2x + 3

---

Code

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-10, 10, 100)

y = 2 * x + 3

plt.plot(
x,
y,
color='green',
label='y = 2x + 3'
)

plt.xlabel("X Values")
plt.ylabel("Y Values")

plt.title("Simple Line Plot")

plt.grid(True)

plt.legend()

plt.show()

---

Explanation

np.linspace(-10, 10, 100)

Creates 100 evenly spaced numbers between -10 and 10.

---

y = 2 * x + 3

Calculates the corresponding Y values.

---

plt.plot()

Draws the graph.

---

plt.grid(True)

Displays grid lines for easier reading.

---

plt.legend()

Displays the graph label.

---

Expected Result

You will see:
- A straight green line
- Crossing the Y-axis at 3
- Increasing continuously because the slope is positive

---

Exercise 2: Comparing Multiple Data Series

Businesses often compare sales between different stores or years.

In this example, we compare product sales between Store A and Store B.

---

Code

import matplotlib.pyplot as plt

products = [
'Laptop',
'Mouse',
'Keyboard',
'Monitor'
]

sales_v1 = [5, 15, 10, 8]
sales_v2 = [7, 12, 11, 9]

plt.bar(
products,
sales_v1,
color='blue',
alpha=0.5,
label='Store A'
)

plt.bar(
products,
sales_v2,
color='red',
alpha=0.5,
label='Store B'
)

plt.title("Sales Comparison by Product")

plt.legend()

plt.show()

---

Explanation

Products:

products = [
'Laptop',
'Mouse',
'Keyboard',
'Monitor'
]

Categories displayed on the X-axis.

---

Sales Data

sales_v1 = [5, 15, 10, 8]
sales_v2 = [7, 12, 11, 9]

Represent sales numbers for two stores.

---

Transparency

alpha = 0.5

Makes bars semi-transparent so overlapping bars remain visible.

---

Legend

plt.legend()

Helps identify which color belongs to which store.

---

Expected Result

A bar chart showing:

- Blue bars → Store A
- Red bars → Store B

This makes comparison quick and easy.

---

Why These Visualizations Matter

Line Charts:
- Show trends
- Show growth or decline
- Useful for predictions

Bar Charts:
- Compare categories
- Compare performance
- Compare products, teams, or departments

---

Real-World Applications

- Business dashboards
- AI model performance analysis
- Student grade comparison
- Financial reports
- Scientific experiments

---

Practice Exercises

1. Modify the line graph and plot:

y = 3x - 5

---

2. Create a bar chart comparing the marks of five students.

---

3. Add:
- X-axis label
- Y-axis label
- Grid
- Legend

to all charts.

---

4. Create a chart comparing:
- Python learners
- Java learners

across four different schools.
Python coding
Statistical_Visualization_Seaborn_Guide.pdf
Basic Python Course
Statistical Visualization with Seaborn

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

1. Introduction to Seaborn

Seaborn is a powerful Python library built on top of Matplotlib.

It is specifically designed for:
- Statistical Visualization
- Data Exploration
- Pattern Discovery
- Correlation Analysis

Seaborn works extremely well with Pandas DataFrames and requires much less code than Matplotlib for advanced visualizations.

---

Why Use Seaborn?

Advantages:

- Beautiful default chart styles
- Easier syntax
- Built-in statistical plots
- Excellent integration with Pandas
- Commonly used in Data Science and AI

---

Importing Seaborn

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

Example dataset:

tips = sns.load_dataset("tips")

The `tips dataset is included with Seaborn and is commonly used for learning and practice.

---

2. Line Plots and Semantic Grouping

Line plots help visualize trends over time.

Seaborn can automatically separate groups using colors with the
hue parameter.

---

Example

``
python
sns.lineplot(
data=df,
x="Year",
y="Sales",
hue="Region"
)

plt.show()

---

Understanding `hue`

The `hue` parameter automatically assigns different colors to categories.

Example:

python
hue = "Region"

Different regions will appear as separate colored lines.

---

Applications

- Sales growth analysis
- Population trends
- Weather tracking
- Business dashboards

---

3. Scatter Plots and Correlation

Scatter plots are used to discover relationships between numerical variables.

---

Example

python
sns.scatterplot(
x="Age",
y="Weight",
data=my_data
)

plt.title("Age vs Weight Correlation")

plt.show()

---

Why Scatter Plots Matter

They help identify:

- Positive correlation
- Negative correlation
- No correlation
- Outliers

---

Example Interpretation

If points move upward from left to right:

text
Age ↑ → Weight ↑

This indicates a positive correlation.

---

4. Box Plots (Five Number Summary)

A box plot summarizes the distribution of data.

It highlights:

- Minimum value
- First Quartile (Q1)
- Median
- Third Quartile (Q3)
- Maximum value

It also helps detect outliers.

---

Example

python
sns.boxplot(
x="day",
y="total_bill",
data=tips
)

plt.show()

---

Why Box Plots Are Useful

They quickly show:

- Data spread
- Skewness
- Median values
- Unusual observations

---

5. Heatmaps and Correlation Matrices

Heatmaps visually represent relationships between variables.

They are extremely important in:

- Machine Learning
- AI Engineering
- Data Analysis

---

Example

python
correlation_matrix = df.corr()

sns.heatmap(
correlation_matrix,
annot=True,
cmap='coolwarm'
)

plt.show()

---

Understanding the Parameters

python
annot=True

Displays the correlation values inside each cell.

---

python
cmap='coolwarm'

Uses a color gradient:

- Blue → Weak or Negative Relationship
- Red → Strong Positive Relationship

---

Why Heatmaps Matter

They help answer questions like:

- Which variables affect sales?
- Which features influence predictions?
- Which columns are strongly related?

---

Real-World Applications of Seaborn

- Data Science
- Artificial Intelligence
- Business Intelligence
- Finance
- Healthcare Analytics
- Scientific Research

---

Comparison: Matplotlib vs Seaborn

| Feature | Matplotlib | Seaborn |
|----------|----------|----------|
| Ease of Use | Moderate | Easy |
| Statistical Charts | Limited | Excellent |
| Default Appearance | Basic | Modern |
| DataFrame Support | Good | Excellent |

---

Statistical Practice Exercises

1. Tips Analysis

Load the `tips` dataset and create a boxplot showing how `total_bill` changes between Lunch and Dinner.

---

2. Hue Challenge

Create a scatter plot showing:

text
total_bill vs tip
`

Color points based on whether the customer is a smoker.

---

3. Clean and Plot

Using your cleaned sales dataset:
Python coding
Statistical_Visualization_Seaborn_Guide.pdf
Create a Seaborn line plot showing:

Price over Date
Python coding
Web_Scraping_BeautifulSoup_Guide.pdf
Basic Python Course
Web Scraping: BeautifulSoup & Requests

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

1. Introduction to Web Scraping

Web scraping is the process of automatically extracting data from websites.

Instead of copying and pasting information manually, Python can read a webpage's HTML and extract specific data automatically. 0

---

Why Learn Web Scraping?

Web scraping is useful for:

- Data Collection
- Market Research
- Price Monitoring
- AI Dataset Creation
- News Aggregation
- Business Intelligence

---

Required Libraries

Install the required libraries:

pip install beautifulsoup4 requests

These libraries help us:
- Download webpage content
- Analyze HTML structure
- Extract useful information

---

2. Fetching Web Content with Requests

The first step is sending a GET request to a website.

This allows Python to download the webpage source code. 1

---

Example

import requests

url = "https://example.com"

response = requests.get(url)

print(response.status_code)

---

Understanding Status Codes

Common status codes:

200 → Success
404 → Page Not Found
500 → Server Error
403 → Access Forbidden

---

3. Parsing HTML with BeautifulSoup

After downloading a webpage, BeautifulSoup converts HTML into a searchable structure. 2

---

Example

from bs4 import BeautifulSoup

soup = BeautifulSoup(
response.content,
"html.parser"
)

print(soup.title.string)

This extracts the webpage title. 3

---

What is HTML?

HTML (HyperText Markup Language) is the language used to build web pages.

Example:

<html>
<head>
<title>My Website</title>
</head>

<body>
<h1>Hello World</h1>
</body>
</html>

BeautifulSoup helps navigate this structure.

---

4. Finding Elements

Web pages contain different HTML tags.

Examples:

<p>Paragraph</p>

<a href="https://example.com">
Link
</a>

BeautifulSoup can search for these elements. 4

---

Finding All Paragraphs

paragraphs = soup.find_all('p')

for p in paragraphs:
print(p.get_text())

---

Finding All Links

links = soup.find_all('a')

for link in links:
print(link.get('href'))

5

---

5. Scraping Tables

Many websites store data inside tables.

This is useful for:
- Product lists
- Student records
- Statistics
- Financial reports

---

Example

table = soup.find('table')

rows = table.find_all('tr')

This finds:
- Table element
- All rows inside the table

6

---

Extracting Table Data

for row in rows:

cols = row.find_all('td')

data = [
ele.text.strip()
for ele in cols
]

print(data)

7

---

How It Works

find_all('tr')

Finds table rows.

---

find_all('td')

Finds table cells.

---

text.strip()

Removes extra spaces.

---

6. Robust Scraping with Exception Handling

Sometimes:

- Websites are offline
- Internet connections fail
- Servers respond slowly

Exception handling prevents your program from crashing. 8

---

Example

try:

response = requests.get(
url,
timeout=10
)

response.raise_for_status()

except requests.exceptions.RequestException as e:

print(f"Error: {e}")

9

---

Why Exception Handling Matters

Without exception handling:

Program crashes

With exception handling:

Program continues safely

---

Real-World Applications

- AI Dataset Collection
- Stock Market Monitoring
- E-commerce Price Tracking
- News Collection
- Social Media Analysis
- Business Research

---

Practice Exercises

1. Page Title Extractor

Write a program that visits a website and prints its title.

---

2. Link Collector

Write a scraper that collects all hyperlinks from a webpage.

---

3. Table Extractor

Find an HTML table and print every row as a Python list.

---

4. Safe Scraper

Modify your scraper using try-except so it handles connection failures without crashing.
Python coding
Python_API_Interaction_Guide.pdf
Basic Python Course
Interacting with APIs

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

1. What is an API?

API stands for Application Programming Interface.

An API is a set of rules that allows one software application to communicate with another.

In Python, APIs are commonly used to:

- Connect to AI models
- Access weather data
- Retrieve map information
- Access social media platforms
- Work with cloud services

---

Real-World Example

When you use a weather app:

Weather App → API → Weather Server

The API acts as the messenger between the application and the server.

---

RESTful APIs

Most modern APIs use REST (Representational State Transfer).

REST APIs communicate using standard HTTP methods.

---

2. HTTP Methods

The most common HTTP methods are:

GET     → Retrieve data
POST → Create new data
PUT → Update existing data
DELETE → Remove data

---

Example Scenario

GET     → Read user information
POST → Create a new account
PUT → Update profile details
DELETE → Delete an account

---

3. Making Requests in Python

Python commonly uses the requests library to communicate with APIs.

---

Import Requests

import requests

---

Example

import requests

url = "https://jsonplaceholder.typicode.com/posts"

response = requests.get(url)

This sends a GET request to the API.

---

Checking the Response

print(response.status_code)

Example Output:

200

---

4. Reading API Data

Many APIs return data in JSON format.

JSON stands for:

JavaScript Object Notation

Python treats JSON data similarly to dictionaries.

---

Convert Response to JSON

data = response.json()

---

Example

if response.status_code == 200:

data = response.json()

print(data[0]["title"])

This prints the title of the first post returned by the API.

---

5. Understanding JSON

JSON stores information as key-value pairs.

Example:

{
"id": 1,
"title": "Hello World",
"userId": 10
}

---

Accessing Values

json_data = response.json()

print(json_data["id"])

---

Accessing Multiple Fields

print(json_data["title"])

print(json_data["userId"])

---

6. Understanding Status Codes

Status codes tell us whether a request succeeded or failed.

---

Common Status Codes

| Code | Meaning | Description |
|--------|--------|--------|
| 200 | OK | Request successful |
| 201 | Created | New resource created |
| 400 | Bad Request | Invalid request |
| 401 | Unauthorized | Missing or invalid authentication |
| 404 | Not Found | Resource does not exist |
| 500 | Server Error | Internal server problem |

---

Example

if response.status_code == 200:
print("Success")
else:
print("Request Failed")

---

7. Why APIs Matter

APIs power most modern software.

Examples:

- ChatGPT API
- Google Maps API
- NASA API
- Weather APIs
- Payment APIs
- Social Media APIs

Without APIs, applications could not easily share information.

---

Real-World Applications

- AI Applications
- Mobile Apps
- Web Development
- Financial Systems
- Data Science
- Automation Tools

---

NASA API Example

The NASA APOD (Astronomy Picture of the Day) API provides daily space images.

Example:

import requests

url = "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"

response = requests.get(url)

data = response.json()

print(data["title"])

print(data["url"])

---

Practice Exercises

1. Fetch Posts

Use:

https://jsonplaceholder.typicode.com/posts

Print the title of the first post.

---

2. Status Checker

Write a program that prints:

Success

if the status code is 200.

Otherwise print:

Request Failed

---

3. JSON Explorer

Create a Python dictionary and practice accessing:

name
age
country

using dictionary keys.

---

4. NASA APOD Challenge

Use the NASA APOD API and print:

Title
Image URL
Explanation
Python coding
Python_Testing_and_Debugging_Guide.pdf
Basic Python Course
Testing and Debugging

By Yehya Oumer
(Certificate from Mizan Institute of Technology)

Issued: 2026

---

1. Introduction to Testing

Testing is the process of checking whether your code behaves as expected.

A program may run without errors but still produce incorrect results.

Testing helps programmers:

- Find bugs early
- Improve reliability
- Prevent future errors
- Build professional software

---

What is Unit Testing?

Unit testing is a technique where individual components such as functions and classes are tested independently.

The goal is to verify that each small part of a program works correctly before integrating it into a larger system.

---

Why Unit Testing Matters

Benefits:

- Detects bugs quickly
- Makes code easier to maintain
- Improves software quality
- Helps developers make changes confidently

---

Pro Tip

If a test fails, you can isolate the bug without worrying about the rest of the application.

---

2. Using the unittest Framework

Python includes a built-in testing framework called unittest.

To create tests:

1. Import unittest
2. Create a class that inherits from unittest.TestCase
3. Write test methods
4. Run the tests

---

Example

import unittest

def add(a, b):
return a + b

class TestMath(unittest.TestCase):

def test_add(self):

self.assertEqual(
add(10, 5),
15
)

self.assertEqual(
add(-1, 1),
0
)

if __name__ == "__main__":
unittest.main()

---

Understanding the Example

add(10, 5)

Expected result:

15

---

``python
assertEqual()
``


Checks whether two values are equal.

If they are not equal, the test fails.

---

unittest.main()

Runs all tests inside the file.

---

3. Common Assert Methods

Assertions are used to verify expected results.

---

Checking Equality

self.assertEqual(a, b)

Verifies:

a == b

---

Checking True Values

self.assertTrue(x)

Verifies that:

x is True

---

Checking Membership

self.assertIn(item, collection)

Verifies that an item exists inside a collection.

Example:

self.assertIn(
"apple",
["apple", "banana"]
)

---

Checking Exceptions

self.assertRaises(Error)

Verifies that specific errors are raised.

Example:

with self.assertRaises(
ZeroDivisionError
):
5 / 0

---

4. Writing Clean Code (PEP 8)

PEP 8 is Python's official style guide.

Following PEP 8 makes code easier to:

- Read
- Maintain
- Debug
- Share with other developers

---

Indentation

Use:

4 spaces

per indentation level.

Example:

if True:
print("Hello")

---

Naming Conventions

Functions and variables:

snake_case

Example:

student_name
calculate_total()

---

Classes

Use:

CamelCase

Example:

StudentManager
BankAccount

---

Line Length

Keep lines below:

79 characters

whenever possible.

---

DRY Principle

DRY means:

Don't Repeat Yourself

Avoid duplicated code.

Bad Example:

print("Welcome")
print("Welcome")
print("Welcome")

Better Example:

for i in range(3):
print("Welcome")

---

5. Debugging Strategies

Debugging is the process of finding and fixing errors.

Every programmer spends a large amount of time debugging.

---

Read the Traceback

When Python encounters an error, it provides a traceback.

Example:

ZeroDivisionError:
division by zero

Read the traceback carefully.

It usually tells you:

- What happened
- Which line failed
- Why it failed

---

Print Debugging

Use print() to inspect variables.

Example:

x = 10

print(x)

This helps verify values during execution.

---

Simplify the Program

Temporarily remove or comment out sections of code.

Example:

# process_data()

Keep simplifying until the source of the bug becomes obvious.

---
Python coding
Python_Testing_and_Debugging_Guide.pdf
Common Programming Errors

Syntax Error

if True
print("Hello")

Missing colon.

---

Name Error

print(username)

Variable not defined.

---

Type Error

"5" + 5

String and integer cannot be added directly.

---

Zero Division Error

10 / 0

Division by zero is not allowed.

---

Why Testing and Debugging Matter

Professional developers do not rely on luck.

They:

- Write tests
- Verify results
- Debug systematically

This leads to reliable and maintainable software.

---

Practice Exercises

1. Create a function called multiply() and write unit tests for it.

---

2. Use assertIn() to verify that "banana" exists inside a list.

---

3. Write a test that confirms dividing by zero raises a ZeroDivisionError.

---

4. Create a program with an intentional bug and use print() debugging to locate the problem.

---

5. Refactor repeated code using the DRY principle.