Skip to content

Latest commit

 

History

History
41 lines (21 loc) · 2.45 KB

programmingQues.md

File metadata and controls

41 lines (21 loc) · 2.45 KB

Programming Assignments

Class Inheritance and Method Overriding

Create a base class Vehicle with attributes make, model, and a method display_info() that prints the make and model. Then, create two subclasses Car and Motorcycle that inherit from Vehicle. Override the display_info() method in each subclass to display additional information specific to cars and motorcycles.

Abstract Base Class and Polymorphism

Define an abstract base class Shape with an abstract method area(). Create subclasses Circle, Rectangle, and Triangle that inherit from Shape. Implement the area() method in each subclass to calculate and return the area of the respective shapes. Write a function that takes a list of shapes and prints their areas.

Exception Handling

Write a program that prompts the user for an integer input. Use a try and except block to handle the case where the user enters a non-integer value. Print an error message if the input cannot be converted to an integer.

File Handling

Write a program that reads a text file and counts the number of occurrences of each word in the file. Create a dictionary where the keys are the words and the values are the counts. Print the dictionary.

Functional Programming

Write a function that takes a list of numbers and returns a new list containing only the even numbers. Use the filter() function along with a lambda function to achieve this.

Advanced Data Structures

Implement a simple stack data structure using a Python list. Create methods push(), pop(), and peek() to manipulate the stack. Test your stack by pushing and popping elements.

Object-Oriented Design

Design a simple banking system with classes Bank, Account, and Transaction. Create methods for opening accounts, depositing and withdrawing funds, and displaying account details. Use encapsulation and proper design principles.

Regular Expressions

Write a program that validates email addresses. Prompt the user to enter an email address and check if it matches a valid email pattern using regular expressions.

Modules and Packages

Create a Python module that defines functions for basic arithmetic operations (addition, subtraction, multiplication, division). Use this module in another script to perform calculations.

Lambda Functions and Sorting

Create a list of tuples, each containing a name and an age. Sort the list based on age using the sorted() function and a lambda function as the key.