⬅ Previous Next ➡

Project & Practice

Mini Project: Quiz System (MCQ Console)
  • Concepts: list/dict, loops, scoring, input validation.
  • Features: random questions, score calculation, result display.
questions = [
    {"q": "Python is a ____ language.", "opt": ["Compiled", "Interpreted", "Machine"], "ans": 2},
    {"q": "Which symbol is used for comments?", "opt": ["//", "#", "/*"], "ans": 2},
    {"q": "What is output of 2**3?", "opt": ["6", "8", "9"], "ans": 2}
]

score = 0

for i, item in enumerate(questions, start=1):
    print(f"\nQ{i}. {item["q"]}")
    for idx, o in enumerate(item["opt"], start=1):
        print(idx, o)

    choice = int(input("Your answer (1-3): "))
    if choice == item["ans"]:
        score += 1

print("\nScore:", score, "/", len(questions))
Project: House Price Prediction (Linear Regression)
  • Goal: predict house price using features like area, bedrooms.
  • Concepts: Pandas, train-test split, LinearRegression, metrics.
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score

df = pd.DataFrame({
    "area": [800, 1000, 1200, 1500, 1800],
    "bedrooms": [1, 2, 2, 3, 3],
    "price": [30, 40, 50, 65, 75]
})

X = df[["area", "bedrooms"]]
y = df["price"]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = LinearRegression()
model.fit(X_train, y_train)

pred = model.predict(X_test)

print("Pred:", pred)
print("MSE:", mean_squared_error(y_test, pred))
print("R2:", r2_score(y_test, pred))
Project: Student Marks Analysis Dashboard
  • Goal: analyze marks and create simple plots.
  • Concepts: Pandas DataFrame, groupby, Matplotlib bar chart.
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame({
    "name": ["A", "B", "C", "D", "E"],
    "dept": ["CSE", "CSE", "IT", "IT", "CSE"],
    "marks": [80, 90, 70, 85, 60]
})

print(df.groupby("dept")["marks"].mean())

avg = df.groupby("dept")["marks"].mean()
avg.plot(kind="bar")
plt.title("Average Marks by Department")
plt.xlabel("Department")
plt.ylabel("Average Marks")
plt.show()
Project: Sales Data Cleaning and Report
  • Goal: clean a dataset (missing + duplicates) and generate summary report.
  • Concepts: fillna, dropna, drop_duplicates, describe.
import pandas as pd
import numpy as np

df = pd.DataFrame({
    "product": ["Pen", "Pen", "Book", "Pencil", None],
    "qty": [10, 10, 5, None, 8],
    "price": [5, 5, 50, 3, None]
})

df = df.drop_duplicates()

df["product"] = df["product"].fillna("Unknown")
df["qty"] = df["qty"].fillna(0)
df["price"] = df["price"].fillna(df["price"].mean())

print(df)
print(df.describe())
Project: Simple Quiz Analytics (CSV + Pandas)
  • Goal: read quiz results from CSV and show top scorers.
  • Concepts: read_csv, sorting, filtering.
import pandas as pd

# sample data
df = pd.DataFrame({
    "name": ["A", "B", "C", "D"],
    "score": [7, 9, 6, 8]
})

df.to_csv("quiz_results.csv", index=False)

data = pd.read_csv("quiz_results.csv")
top = data.sort_values(by="score", ascending=False).head(3)

print("Top 3:")
print(top)
Project: Movie Ratings Visualization
  • Goal: visualize ratings using histogram and bar chart.
  • Concepts: Matplotlib hist, bar.
import matplotlib.pyplot as plt

movies = ["M1", "M2", "M3", "M4", "M5"]
ratings = [4.2, 3.8, 4.5, 4.0, 3.5]

plt.bar(movies, ratings)
plt.title("Movie Ratings")
plt.xlabel("Movie")
plt.ylabel("Rating")
plt.ylim(0, 5)
plt.show()

plt.hist(ratings, bins=5)
plt.title("Ratings Distribution")
plt.xlabel("Rating")
plt.ylabel("Frequency")
plt.show()
⬅ Previous Next ➡