๐Ÿ“Œ List of Python Practical Exercises

This is a structured list of Python exercises, covering basic to advanced topics with important mathematical and real-world problems like factorial, Armstrong number, prime number, and matrix operations.


๐Ÿ”น 1๏ธโƒฃ Python Basics

1. Check Python Version

โœ… Exercise: Write a program to display the installed Python version.

2. Variables and Data Types

โœ… Exercise: Define variables of different types and print their values and types.

3. Data Type Conversion

โœ… Exercise: Convert integer to string, float to integer, and string to float.

4. Arithmetic and Comparison Operators

โœ… Exercise: Perform addition, subtraction, multiplication, division, modulus, and exponentiation.

5. Logical and Identity Operators

โœ… Exercise: Check if a given number is positive and even using logical operators.


๐Ÿ”น 2๏ธโƒฃ Control Statements

6. Decision Making (if-else)

โœ… Exercise: Check if a number is positive, negative, or zero.

7. Check Even or Odd

โœ… Exercise: Write a program to check if a number is even or odd.

8. Find the Largest of Three Numbers

โœ… Exercise: Take three numbers as input and find the largest number.


๐Ÿ”น 3๏ธโƒฃ Loops in Python

9. Print Numbers from 1 to N

โœ… Exercise: Use for and while loops to print numbers from 1 to N.

10. Print Multiplication Table

โœ… Exercise: Display the multiplication table of a given number.

11. Sum of First N Natural Numbers

โœ… Exercise: Find the sum of the first N natural numbers using loops.

12. Factorial of a Number

โœ… Exercise: Write a program to compute the factorial of a number using a loop.
๐Ÿ“Œ Example: 5! = 5 ร— 4 ร— 3 ร— 2 ร— 1 = 120

13. Fibonacci Series

โœ… Exercise: Print the first N numbers in the Fibonacci series.

14. Armstrong Number

โœ… Exercise: Check if a number is an Armstrong number (sum of cubes of digits equals the number).
๐Ÿ“Œ Example: 153 = (1ยณ) + (5ยณ) + (3ยณ) = 153

15. Prime Number Check

โœ… Exercise: Write a program to check whether a number is prime or not.

16. Reverse a Number

โœ… Exercise: Reverse a given number (e.g., 123 โ†’ 321).


๐Ÿ”น 4๏ธโƒฃ Strings and Lists

17. String Operations

โœ… Exercise: Convert a string to uppercase, lowercase, and reverse it.

18. Palindrome Check (String & Number)

โœ… Exercise: Check whether a given string or number is a palindrome.
๐Ÿ“Œ Example: 121 โ†’ Palindrome, "madam" โ†’ Palindrome

19. Count Vowels and Consonants in a String

โœ… Exercise: Write a program to count vowels and consonants in a given string.

20. Remove Duplicates from a List

โœ… Exercise: Remove duplicate elements from a given list.


๐Ÿ”น 5๏ธโƒฃ Functions in Python

21. Function to Find Factorial

โœ… Exercise: Write a function to compute factorial using recursion.

22. Function to Check Armstrong Number

โœ… Exercise: Create a function that checks Armstrong numbers.

23. Function to Find Maximum in a List

โœ… Exercise: Write a function to return the largest number in a list.


๐Ÿ”น 6๏ธโƒฃ File Handling in Python

24. Read and Write to a File

โœ… Exercise: Create a file, write a message, and read it.

25. Count Words in a File

โœ… Exercise: Read a file and count the number of words.

26. Copy Contents of One File to Another

โœ… Exercise: Copy text from one file to another.


๐Ÿ”น 7๏ธโƒฃ Object-Oriented Programming (OOP)

27. Create a Class and Object

โœ… Exercise: Define a class Car with attributes and methods, and create an object.

28. Inheritance in Python

โœ… Exercise: Create a parent class Animal and a child class Dog that inherits from Animal.

29. Method Overloading (Simulated)

โœ… Exercise: Write a class Math with an overloaded method add() (using default parameters).

30. Method Overriding

โœ… Exercise: Override a parent class method in a child class.

31. Polymorphism Example

โœ… Exercise: Use a common function to call speak() from different classes (Cat, Dog).


๐Ÿ”น 8๏ธโƒฃ Advanced Programs

32. Matrix Addition

โœ… Exercise: Write a program to add two matrices.
๐Ÿ“Œ Example:

Matrix 1:  [[1, 2], [3, 4]]
Matrix 2:  [[5, 6], [7, 8]]
Result:    [[6, 8], [10, 12]]

33. Transpose of a Matrix

โœ… Exercise: Compute the transpose of a matrix.

34. Merge Two Sorted Lists

โœ… Exercise: Write a function to merge two sorted lists into one sorted list.

35. Find Second Largest Number in a List

โœ… Exercise: Find the second largest number in a list.

36. Find GCD and LCM of Two Numbers

โœ… Exercise: Write a function to compute the GCD and LCM of two numbers.

37. Generate a Random Password

โœ… Exercise: Use the random module to generate a random strong password.

38. Implement a Simple Calculator

โœ… Exercise: Create a basic calculator that can perform addition, subtraction, multiplication, and division.

39. Count Frequency of Words in a String

โœ… Exercise: Write a Python program to count occurrences of each word in a given string.


๐Ÿ”น Summary Table

Category Exercises Included
Python Basics Variables, Operators, Type Conversion
Control Statements If-else, Largest Number, Even/Odd
Loops Factorial, Fibonacci, Armstrong, Prime
Strings & Lists Palindrome, Reverse, Count Vowels, Remove Duplicates
Functions Factorial, Armstrong Check, Find Maximum
File Handling Read/Write File, Copy Contents, Count Words
OOP Concepts Class & Object, Inheritance, Overloading, Overriding, Polymorphism
Advanced Programs Matrix Addition, Transpose, GCD/LCM, Random Password, Calculator

๐Ÿ”ฅ Final Challenge

๐Ÿ”น Create a Simple Student Management System
โœ… Add student records (name, age, course).
โœ… Store and retrieve records from a file.
โœ… Provide options to add, delete, update, and search students.


๐Ÿ“Œ Conclusion

This comprehensive list of exercises will help you understand Python from basics to advanced level. Let me know if you need solutions or additional challenges! ๐Ÿš€


Leave a Reply

Your email address will not be published. Required fields are marked *