0% found this document useful (0 votes)
5 views

Programming_Exercises_Aligned

The document outlines a series of programming exercises aimed at enhancing coding skills in various areas such as number manipulation, file handling, class inheritance, and exception handling. Each exercise presents a specific task, ranging from reversing digits and managing inventories to implementing customer feedback systems and demonstrating object-oriented programming concepts. The exercises are designed to cover fundamental programming concepts and practical applications in Python.

Uploaded by

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

Programming_Exercises_Aligned

The document outlines a series of programming exercises aimed at enhancing coding skills in various areas such as number manipulation, file handling, class inheritance, and exception handling. Each exercise presents a specific task, ranging from reversing digits and managing inventories to implementing customer feedback systems and demonstrating object-oriented programming concepts. The exercises are designed to cover fundamental programming concepts and practical applications in Python.

Uploaded by

laxma reddy ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Programming Exercises

1. Write a program to reverse the digits of a given number and add it to the original.

If the sum is not a palindrome, repeat this procedure.

2. Write a program using a while loop that asks the user for a number and prints

a countdown from that number to zero.

3. Write a program to calculate a student's result based on two examinations, one sports event,

and three activities conducted.

- The weightage of activities = 30%, sports = 20%, and examinations = 50%.

4. Write a program to convert a floating-point number into the corresponding integer.

5. Write a program to prepare a grocery bill. Enter the name of the items purchased, quantity,

and price per unit. Then display the bill.

6. Write a program that shows how to return multiple values from a function.

7. A string is given. Slice it into two parts: the first half and the second half.

If the string has an odd length, the second half will have one more character than the first half.

8. Write programs on regular expressions.

9. You are given a list of integers and a series of operations.

- Input:
- The first line contains an integer n, representing the number of operations.

- The next n lines contain operations such as append x or remove x.

- Output:

- After each operation, print the current state of the list.

10. Write a program to store Fibonacci numbers in a list and sum even terms.

11. Inventory Management System:

- Manage an inventory system. Inventory items will be stored as tuples (item name, price).

The list of items in the inventory will be dynamic.

12. Write programs on dictionaries.

13. Write a program to unzip a list of tuples into individual lists and convert them into a dictionary.

14. Write a program to use split and join methods in a string and trace a birthday with a dictionary.

15. E-Commerce Product Catalog Management:

- Manage the product catalog for an e-commerce website. The catalog needs to store:

- Product ID, name, price, category, and stock.

- Operations:

- Add new products.

- Update existing product details.

- Search for a product by ID.

- Calculate the total value of products in stock.

16. Write programs on handling files.


17. Write a program to count the frequency of characters in a file.

Use character frequency to infer the file type (e.g., Python, C, or text).

18. Write a program to compute the number of characters, words, and lines in a file.

19. Case Study: Customer Feedback Management System using Files:

- Collect feedback from customers stored in a file.

- Read multiple customer feedback submissions.

- Add new feedback entries.

- Search feedback by customer name.

- Summarize feedback (e.g., positive or negative counts).

20. Demonstrate class variables, instance variables, and the self-variable:

- Robot class.

- ATM Machine class.

21. Write a program to differentiate private and public variables in a class.

22. Write a program to demonstrate built-in functions to check, get, set, and delete class attributes.

23. Programs on Inheritance and Polymorphism.

24. Create a Person class with attributes name and age. Create a Student class that

inherits from Person and adds a grade attribute.

25. Create a Shape class with methods like area() and perimeter(). Derive Circle,
Rectangle, and Triangle classes for specific calculations.

26. Use constructors (__init__()) in both parent and child classes. Demonstrate how the child class

initializes both its own attributes and inherited attributes using super().

27. Create a program where the child class overrides a method of the parent class (e.g.,

display_details()).

28. Overload operators like + or * in a class to perform custom operations (e.g., adding two Vector

objects).

29. Create a base class Product and child classes Electronics, Clothing, and Grocery.

Add a polymorphic method get_discount().

30. Create a base class Transport and subclasses Car, Bus, and Bicycle.

Each subclass overrides a method (e.g., fuel_cost()).

31. Write programs on Exception Handling.

32. Demonstrate various techniques of exception handling in Python:

- Basic exception handling (try, except).

- Handling multiple exceptions.

- Raising custom exceptions.

- Handling exceptions with files.

You might also like