Skip to content

Commit 4bbeba3

Browse files
committed
updated
1 parent 57e3a62 commit 4bbeba3

18 files changed

+354
-0
lines changed

Inheritance/Basic.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Inheritance allows a class (child class) to reuse attributes and methods from another class (parent class).
2+
3+
class parent:
4+
def greet(self):
5+
print("hello, from parent")
6+
7+
8+
class child(parent):
9+
def greet2(self):
10+
print("hello, from child")
11+
pass # inherits everything from parent
12+
13+
14+
obj = child()
15+
obj.greet()
16+
obj.greet2()

Inheritance/ConstructorInheritance.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# The __init__() method is a constructor in Python that is automatically called when an object of a class is created.
2+
# In inheritance, its behavior can be controlled to initialize attributes in both parent and child classes.
3+
4+
5+
class parent:
6+
def __init__(self):
7+
print("Parent Constructor")
8+
9+
10+
class Child(parent):
11+
def __init__(self):
12+
super().__init__() # super() function is used access the constructor of parent class
13+
print("Child Constructor")
14+
15+
16+
# If a child class defines its own __init__(), it overrides the parent’s constructor.
17+
class child1(parent):
18+
def __init__(self):
19+
print("child1 constructor")
20+
21+
22+
obj = Child()
23+
obj1 = child1()
24+
25+
26+
# If the parent class has parameters, we must pass arguments using super().
27+
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Hierarchical Inheritance:In this multiple child inherit a single parent
2+
# like here we 'A' and 'B' inherit 'parent', i.e., obj of both 'A' and 'B' can access function/variable of parent class
3+
class parent:
4+
def common(self):
5+
print("parent")
6+
7+
8+
class A(parent):
9+
def feature1(self):
10+
print("A")
11+
12+
13+
class B(parent):
14+
def feature2(self):
15+
print("B")
16+
17+
18+
obj1 = A()
19+
obj2 = B()
20+
obj1.common()
21+
obj2.common()

Inheritance/MultilevelInheritance.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# A child class inherits from another child class.
2+
# here {Grandparent <-- Parent <-- child}, child has properties of both parent and grandparent, therefore we can access their function with the help of obj of 'child'
3+
4+
5+
class Grandparent:
6+
def feature1(self):
7+
print("Feature from Grandparent")
8+
9+
10+
class Parent(Grandparent):
11+
def feature2(self):
12+
print("Feature from Parent")
13+
14+
15+
class Child(Parent):
16+
def feature3(self):
17+
print("Feature from Child")
18+
19+
20+
obj = Child()
21+
obj.feature1() # From Grandparent
22+
obj.feature2() # From Parent
23+
obj.feature3() # Defined in Child

Inheritance/MultipleInheritance.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Multiple Inheritance : in multiple inheritance a class can have multiple parents,
2+
# like here 'C' is inheriting 'A' as well as 'B'
3+
class A:
4+
def a(self):
5+
print("this is a")
6+
7+
8+
class B:
9+
def b(self):
10+
print("this is b")
11+
12+
13+
class C(A, B):
14+
pass
15+
16+
17+
obj = C()
18+
obj.a()
19+
obj.b()

Inheritance/overriding.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Overriding is a concept , in which we have same function name, in both the parent and child class, but with a different body,
2+
# (OR)
3+
# Overriding means redefining a method in the child class that already exists in the parent class .
4+
# The child class replaces the parent's method with its own version.
5+
class parent:
6+
def show(self):
7+
print("parent class")
8+
9+
10+
class child(parent):
11+
def show(self):
12+
print("child class")
13+
14+
15+
obj = child()
16+
obj.show()

Inheritance/super.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# super keyword: it is used to access the functions of parent class
2+
class parent:
3+
def show(self):
4+
print("parent class")
5+
6+
7+
class child(parent):
8+
def show(self):
9+
super().show()
10+
print("this is child class")
11+
12+
13+
obj = child()
14+
obj.show()

Project-01/README.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# 📚 CLI-Based Student Management System
2+
3+
## Overview
4+
A simple CLI-based Student Management System that:
5+
✅ Uses custom exceptions for input validation (e.g., invalid age, duplicate ID)
6+
✅ Uses file handling to store student data persistently
7+
✅ Implements OOP (Object-Oriented Programming) for better structure
8+
✅ Follows a menu-driven CLI format
9+
10+
## Features
11+
- Add a student (ID, name, age)
12+
- View all students
13+
- Search for a student by ID
14+
- Delete a student
15+
- Exit
16+
17+
## Why Use a CLI Tool?
18+
✅ Lightweight and fast ⚡
19+
✅ Can be used remotely (e.g., SSH into a server)
20+
✅ Ideal for automation tasks
21+
✅ Easy to integrate into scripts
22+
23+
## 🖥️ Examples of CLI Tools:
24+
- git (Version Control)
25+
- pip (Python Package Manager)
26+
- ls, cd, mkdir (Linux commands)
27+
28+
# 🚀 Project Overview
29+
This project is a ** Command Line Interface(CLI) Student Management System ** that allows users to manage student records efficiently. It follows ** Object-Oriented Programming(OOP) ** principles and incorporates ** custom exceptions ** for input validation. Additionally, student data is stored using ** file handling ** for persistence.
30+
31+
# ✨ Features
32+
✅ Add a student(ID, name, age)
33+
✅ View all students
34+
✅ Search for a student by ID
35+
✅ Delete a student
36+
✅ Exit
37+
38+
# 🛠 Technologies Used
39+
- **Python ** (Core programming language)
40+
- **File Handling ** (For persistent storage)
41+
- **Custom Exceptions ** (For error handling)
42+
- **OOP(Object-Oriented Programming) ** (For better code structure)
43+
44+
# 📂 File Structure
45+
```
46+
StudentManagementSystem/
47+
│── main.py # Entry point of the program
48+
│── student.py # Student class definition
49+
│── student_manager.py # Handles student operations
50+
│── students.txt # Stores student data
51+
│── exceptions.py # Custom exceptions for validation
52+
│── README.md # Project documentation
53+
```
54+
55+
# 🎯 How It Works
56+
# 1️⃣ **Add a Student**
57+
- Users can add a student by providing a ** unique ID, name, and age**.
58+
- The system validates the input and prevents duplicate IDs.
59+
- Data is stored in a file for persistence.
60+
61+
# 2️⃣ **View All Students**
62+
- Displays all student records stored in the file.
63+
- Ensures data is retrieved in a readable format.
64+
65+
# 3️⃣ **Search for a Student by ID**
66+
- Users can enter a ** Student ID ** to find a specific record.
67+
- Returns details if the student exists
68+
otherwise, shows an error message.
69+
70+
# 4️⃣ **Delete a Student**
71+
- Users can delete a student using their ** ID**.
72+
- The system removes the entry from the file.
73+
74+
# 5️⃣ **Exit the Program**
75+
- Ends the CLI session gracefully.
76+
77+
# ⚙️ How to Run the Program
78+
# Step 1️⃣: Clone the Repository
79+
```sh
80+
git clone https: // github.com/your-username/StudentManagementSystem.git
81+
cd StudentManagementSystem
82+
```
83+
84+
# Step 2️⃣: Run the Program
85+
```sh
86+
python main.py
87+
```
88+
89+
# 🚨 Custom Exception Handling
90+
The system uses custom exceptions for:
91+
- **Invalid Age Exception**: Ensures the age is a positive integer.
92+
- **Duplicate ID Exception**: Prevents adding students with the same ID.
93+
- **Student Not Found Exception**: Handles errors when searching for non-existent students.
94+
95+
# 📝 Future Enhancements
96+
- Implement a ** GUI version ** of the system.
97+
- Add ** database storage ** instead of file handling.
98+
- Include ** student grade tracking**.
99+
100+
# 💡 Contributing
101+
Contributions are welcome! Feel free to submit issues and pull requests.
102+
103+
# � License
104+
This project is open-source and available under the ** MIT License**.
105+
106+
---
107+
Developed with ❤️ by[Rohit]

Project-01/Student-management/exceptions.py

Whitespace-only changes.

Project-01/Student-management/main.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
3+
def add_student():
4+
Name = input("Enter student name: ")
5+
Roll_no = int(input("Enter student roll no.: "))
6+
Age = int(input("Enter student age: "))
7+
CGPA = float(input("Enter student CGPA:"))
8+
print(f"Student Name:{Name}\nRoll_no:{Roll_no}\nAge: {Age}\nCGPA: {CGPA}")
9+
10+
11+
def view_student():
12+
13+
14+
def delete_student():
15+
16+
# with open("student.txt", "w") as file:
17+
18+
19+
def option_1():
20+
print("Add student")
21+
add_student()
22+
23+
24+
def option_2():
25+
print("View student")
26+
view_student()
27+
28+
29+
def option_3():
30+
print("Delete student")
31+
delete_student()

Project-01/Student-management/student.py

Whitespace-only changes.

Project-01/Student-management/student.txt

Whitespace-only changes.

Project-01/Student-management/student_manager.py

Whitespace-only changes.

Project-01/project.txt

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Great approach! Here’s your **step-by-step roadmap** to building the **CLI-based Student Management System** 🚀
2+
3+
---
4+
5+
### **Step 1: Plan the Features**
6+
Your CLI should allow users to:
7+
✅ **Add students** (Name, Roll Number, Marks)
8+
✅ **View all students**
9+
✅ **Search for a student by Roll Number**
10+
✅ **Delete a student**
11+
✅ **Exit the program**
12+
13+
---
14+
15+
### **Step 2: Structure the Project**
16+
Break it down into logical parts:
17+
1️⃣ **Main Program (CLI Loop)** – This will continuously prompt users for input.
18+
2️⃣ **Functions** for each feature (e.g., `add_student()`, `view_students()`).
19+
3️⃣ **Data Storage** – Use a file (`students.txt` or JSON) to store student records.
20+
4️⃣ **Custom Exceptions** for handling invalid inputs.
21+
5️⃣ **Object-Oriented Programming (OOP)** for a well-structured approach.
22+
23+
---
24+
25+
### **Step 3: Implement Basic CLI Loop**
26+
- Use an infinite loop (`while True`) to keep the program running.
27+
- Display a **menu** with options (1. Add Student, 2. View, etc.).
28+
- Use `input()` to take user choices and call respective functions.
29+
- Provide an **exit option** (`break` the loop).
30+
31+
---
32+
33+
### **Step 4: Implement Core Functionalities**
34+
1️⃣ **Add Student**
35+
- Take user input (Name, Roll No, Marks).
36+
- Store it in a file (`students.txt` or `students.json`).
37+
38+
2️⃣ **View Students**
39+
- Read the file and display all students.
40+
41+
3️⃣ **Search Student**
42+
- Ask for Roll Number and find in the file.
43+
44+
4️⃣ **Delete Student**
45+
- Remove a student's data by Roll Number and update the file.
46+
47+
5️⃣ **Handle Edge Cases**
48+
- What if the file is empty?
49+
- What if the Roll Number doesn’t exist?
50+
- What if the user enters invalid input?
51+
52+
---
53+
54+
### **Step 5: Add Exception Handling & Validation**
55+
- Use **try-except** to catch input errors.
56+
- Implement a **custom exception** like `StudentNotFoundError`.
57+
58+
---
59+
60+
### **Step 6: Test Your CLI Tool**
61+
- Test with different inputs.
62+
- Try edge cases (searching for a non-existing student, deleting from an empty file).
63+
- Handle unexpected inputs (e.g., entering text instead of a number).
64+
65+
---
66+
67+
### **Final Step: Improve & Optimize**
68+
🔹 **Add Data Persistence** – Store students in JSON instead of text for better structure.
69+
🔹 **Make the CLI User-Friendly** – Use formatting (`print(f"{name: <10} {roll: <5} {marks: <5}")`).
70+
🔹 **Expand Features** – Add grade calculation, sorting, or updating student records.
71+
72+
---
73+
74+
That’s your **roadmap!** 🛣️🔥 You can start coding step by step and ask me for help anytime.
75+
76+
Which step would you like to begin with? 🚀
217 Bytes
Binary file not shown.

miscellaneous/generate_calendar.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import calendar
2+
yy = 2025
3+
mm = 3
4+
print(calendar.month(yy, mm))
File renamed without changes.

student.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)