⦁ NumPy: Numerical Computing ⚙️
NumPy is the foundation for numerical operations in Python. It provides fast arrays and math functions.
Example:
import numpy as np
arr = np.array([1, 2, 3])
print(arr * 2) # [2 4 6]
Challenge: Create a 3x3 matrix of random integers from 1–10.
matrix = np.random.randint(1, 11, size=(3, 3))
print(matrix)
⦁ Pandas: Data Analysis 🐼
Pandas makes it easy to work with tabular data using DataFrames.
Example:
import pandas as pd
data = {"Name": ["Alice", "Bob"], "Age": [25, 30]}
df = pd.DataFrame(data)
print(df)
Challenge: Load a CSV file and show the top 5 rows.
df = pd.read_csv("data.csv")
print(df.head())
⦁ Matplotlib: Data Visualization 📊
Matplotlib helps you create charts and plots.
Example:
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [2, 4, 1]
plt.plot(x, y)
plt.title("Simple Line Plot")
plt.show()
Challenge: Plot a bar chart of fruit sales.
fruits = ["Apples", "Bananas", "Cherries"]
sales = [30, 45, 25]
plt.bar(fruits, sales)
plt.title("Fruit Sales")
plt.show()
⦁ Seaborn: Statistical Plots 🎨
Seaborn builds on Matplotlib with beautiful, high-level charts.
Example:
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
sns.boxplot(x="day", y="total_bill", data=tips)
plt.show()
Challenge: Create a heatmap of correlation.
corr = tips.corr()
sns.heatmap(corr, annot=True, cmap="coolwarm")
plt.show()
⦁ Requests: HTTP for Humans 🌐
Requests makes it easy to send HTTP requests.
Example:
import requests
response = requests.get("https://api.github.com")
print(response.status_code)
print(response.json())
Challenge: Fetch and print your IP address.
res = requests.get("https://api.ipify.org?format=json")
print(res.json()["ip"])
⦁ Beautiful Soup: Web Scraping 🍜
Beautiful Soup helps you extract data from HTML pages.
Example:
from bs4 import BeautifulSoup
import requests
url = "https://example.com"
html = requests.get(url).text
soup = BeautifulSoup(html, "html.parser")
print(soup.title.text)
Challenge: Extract all links from a webpage.
links = soup.find_all("a")
for link in links:
print(link.get("href"))
Next Steps:
⦁ Combine these libraries for real-world projects
⦁ Try scraping data and analyzing it with Pandas
⦁ Visualize insights with Seaborn and Matplotlib
Double Tap ♥️ For More