0% found this document useful (0 votes)
7 views9 pages

Python OOP Projects for Beginners

The document outlines a series of programming tasks focused on building classes in Python, covering various concepts such as OOP, encapsulation, inheritance, and polymorphism. Each task includes creating specific classes with attributes and methods, such as Student, BankAccount, and Calculator, along with testing their functionalities. Additionally, advanced topics like abstract classes, static methods, and file handling are also addressed in the tasks.

Uploaded by

justanoal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views9 pages

Python OOP Projects for Beginners

The document outlines a series of programming tasks focused on building classes in Python, covering various concepts such as OOP, encapsulation, inheritance, and polymorphism. Each task includes creating specific classes with attributes and methods, such as Student, BankAccount, and Calculator, along with testing their functionalities. Additionally, advanced topics like abstract classes, static methods, and file handling are also addressed in the tasks.

Uploaded by

justanoal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PYTHON – LOGIC BUILDING & OOP

Q1. Student Class


Create a class Student with attributes: name, age, and grade.
 Add a method get_details() that prints the student’s
information.
 Create 3 student objects and display their details.

Q2. Bank Account


Create a class BankAccount with:
 Attributes: account_number, balance.
 Methods:
o deposit(amount) → adds money.
o withdraw(amount) → subtracts money if enough
balance.
o check_balance() → shows current balance.
 Create an account and test the methods.

Q3. Calculator Class


Make a class Calculator with methods:
 add(x, y)
 subtract(x, y)
 multiply(x, y)
 divide(x, y) → handle division by zero.
 Create an object and test all methods.
Q4. Rectangle Area & Perimeter
Create a class Rectangle with attributes length and width.
 Add methods:
o area() → returns area.
o perimeter() → returns perimeter.
 Create two rectangles and compare their areas.

Q5. Employee Salary Calculator


Create a class Employee with:
 Attributes: name, salary.
 Method: apply_bonus(percentage) → increases salary.
 Method: get_salary() → prints current salary.

Q6. Animal Inheritance


Create a base class Animal with method speak().
 Create subclasses Dog and Cat that override speak() to print
"Woof!" and "Meow!".
 Create objects of each and call speak().

Q7. Library Management


Create a class Book with attributes: title, author, copies.
 Method borrow_book() → decreases copies if available.
 Method return_book() → increases copies.
 Create a few books and simulate borrowing/returning.

Q8. Shopping Cart (Encapsulation)


Create a class ShoppingCart:
 Use a private attribute __items (dictionary with item → price).
 Methods:
o add_item(item, price)
o remove_item(item)
o get_total() → returns total price.
 Test with some items.
Advanced OOP (Polymorphism, Abstraction, Class
Methods)

Q9. Shape Polymorphism


Create an abstract class Shape with abstract method area().
 Create subclasses Circle, Square, and Triangle.
 Implement the area() method for each.
 Demonstrate polymorphism by iterating over shapes.

Q10. Vehicle Class with Inheritance


Create a base class Vehicle with attributes brand, model.
 Subclasses: Car, Motorcycle.
 Each should have its own method drive().
 Create objects and call methods.
Q11. Student Database (Class Method)
Create a class Student with:
 Attributes: name, id.
 A class variable student_count that tracks how many
students were created.
 A class method get_count() that returns total students
created.

Q12. Online Quiz System


Create classes for a small quiz:
 Question → stores question text, options, and correct answer.
 Quiz → stores multiple questions, asks user, keeps score.
 Test with at least 3 questions.

Q13. University Management System


Create a class Person with attributes name and age.
 Subclass Professor with an additional attribute department.
 Subclass Student with an additional attribute major.
 Both should have a method get_details() that displays their
information.
 Store multiple professors and students in a list and print
their details.
Q14. Banking System with Interest (Inheritance +
Method Overriding)
Create a base class BankAccount with:
 deposit(), withdraw(), get_balance().
Create subclass SavingsAccount that:
 Adds method add_interest(rate) to increase balance.
 Overrides withdraw() so balance cannot go below a
minimum.

Q15. Employee Management (Static Method)


Create a class Employee:
 Attributes: name, salary.
 A static method is_valid_salary(salary) that checks if salary
≥ 3000.
 A class variable employee_count to track number of
employees.
 A method display_info() to show employee details.

Q16. Online Store Simulation


 Create a class Product with attributes: id, name, price, stock.
 Create a class Store that holds a list of products.
o Methods:
 add_product()
 buy_product(id, qty) (decreases stock)
 display_products()
 Simulate buying items from the store.
Q17. School Grading System
Create a class Course with attributes name, credits.
Create a class Student:
 Attributes: name, grades (dictionary of course → marks).
 Method add_grade(course, mark).
 Method get_gpa() → calculate GPA from all courses.

Q18. File Handling with OOP


Create a class FileManager:
 Method write_to_file(filename, content) → writes data.
 Method read_from_file(filename) → reads and prints content.
 Method append_to_file(filename, content) → adds new
content at the end.

Q19. Transport Ticket Booking System


Create classes:
 Passenger → stores passenger details.
 Ticket → stores ticket number, destination, and price.
 BookingSystem → manages bookings (list of tickets).
o Method book_ticket(passenger, destination) →
generates ticket.
o Method show_bookings() → shows all tickets booked.
Q20. Inventory Management (Encapsulation + File
Handling)
Create a class Inventory:
 Use a private dictionary __items to store item name and
quantity.
 Methods:
o add_item(name, qty)
o remove_item(name, qty) (only if enough stock)
o view_items()
 Save inventory to a file after each update.

Q21. Polymorphism Example – Payment System


Create a base class Payment with method
make_payment(amount).
 Subclass CreditCardPayment → print "Paid {amount} using
credit card".
 Subclass PayPalPayment → print "Paid {amount} using
PayPal".
 Demonstrate polymorphism by calling make_payment() on
both.

Q22. Hospital Management System


Create classes:
 Person → base class with name, age.
 Doctor → subclass with specialization.
 Patient → subclass with illness.
 Hospital → manages lists of doctors and patients.
o Methods to add_doctor(), add_patient(), list_doctors(),
list_patients().

Q23. Game Character System (Inheritance +


Polymorphism)
Create a base class Character with attributes name, health.
 Subclasses:
o Warrior → method attack() reduces enemy health by 10.
o Wizard → method attack() reduces enemy health by 15.
 Simulate a small battle between two characters.

Q24. Airline Reservation System


Create classes:
 Flight → flight number, destination, available seats.
 Passenger → name, passport number.
 ReservationSystem → allows booking seats, cancelling, and
displaying reservations.

Q25. Banking Transactions Log (File + OOP)


Create a Transaction class with: transaction_id, type
(deposit/withdraw), amount.
Create a BankAccount class that:
 Has methods deposit() and withdraw().
 Stores each transaction in a file ([Link]).
 A method show_transactions() reads the file and displays all
transactions.

You might also like