Py Ass12
Py Ass12
1. Create a Person class with attributes 'name' and 'age'. Include a method 'introduce' that
prints a message introducing the person.
2. Create a 'Car' class with attributes 'make', 'model', and 'year'. Include a method 'display_info'
that prints the car's details.
3. Create a 'BankAccount' class with attributes 'account_number' and 'balance'. Include methods
'deposit' and 'withdraw' to modify the balance, and a method 'display_balance' to print the
current balance.
4. Create a 'Rectangle' class with attributes 'length' and 'width'. Include methods to calculate the
area and perimeter of the rectangle.
5. Create a 'Student' class with attributes 'name' and 'grades' (a list). Include methods to
calculate the average grade and print the student's details.
6. Create an 'Employee' class with attributes 'name', 'position', and 'salary'. Include a method to
give the employee a raise by a certain percentage and print the updated salary.
7. Create a 'Library' class that manages a collection of books. Include methods to add a book,
remove a book, and display all books.
8. Create a 'Circle' class with attribute 'radius'. Include methods to calculate the area and
circumference of the circle.
9. Create a 'Book' class with attributes 'title', 'author', and 'year'. Include a method to print the
book's details and a method to check if the book is a classic (published more than 50 years ago).
10. Create a 'Shape' class with a method 'area' that returns 0. Then create subclasses 'Square'
and 'Triangle' that override the 'area' method to return the correct area for each shape.