Python assignment-2
Inheritance
1. Write a Python program to create a person class. Include attributes like
name, country and date of birth. Implement a method to determine the
person's age.
2. Write a Python program to create a calculator class. Include methods
for basic arithmetic operations.
3. Write a Python program to create a class that represents a shape.
Include methods to calculate its area and perimeter. Implement
subclasses for different shapes like circle, triangle, and square.
4. Write a Python program to create a class representing a stack data
structure. Include methods for pushing and popping elements.
5. Write a Python program to demonstrate multiple inheritance.
6. Write a Python program to demonstrate Multi level inheritance.
7. Write a Python program to demonstrate method overriding.
Exception Handling
8. Write a Python program to handle a ZeroDivisionError exception when
dividing a number by zero.
9. Write a Python program that prompts the user to input an integer and
raises a ValueError exception if the input is not a valid integer.
10. Write a Python program that opens a file and handles a
FileNotFoundError exception if the file does not exist.
11. Write a Python program that prompts the user to input two numbers and
raises a TypeError exception if the inputs are not numerical
12. Write a Python program that executes an operation on a list and
handles an IndexError exception if the index is out of range.
13. Write a Python program that executes a list operation and handles an
AttributeError exception if the attribute does not exist.
14. Write a python program to demonstrate else with try statement.
15. Write a python program to demonstrate use of finally.
16. Write a python program to create a custom exception.
Data Base connectivity
17. Write a Python program to create a table and insert some records in
that table. Finally selects all rows from the table and display the records.
18. Write a Python program to insert values to a table from user input.
19. Write a Python program to update a specific column value of a given
table and select all rows before and after updating the said table.
20. Write a Python program to delete a specific row from a given table and
after deletion display records.
21. Write a Python program to alter a given table.