Practical Question of Python
Practical Question of Python
1. Write a program that asks the user to input a number and checks if it's even or odd.
2. Create a program that accepts two numbers and swaps their values using only variable
assignments.
3. Write a program to calculate the area and circumference of a circle given its radius.
10. Create a list of numbers and display the second highest number.
11. Write a program to find the sum and average of elements in a list.
12. Write a program to reverse a string without using built-in reverse functions.
13. Create a dictionary where keys are countries and values are their capitals. Display all
country-capital pairs.
14. Write a program to find the largest number in a tuple.
15. Create a set from a list and perform set operations like symmetric difference and union.
Unit 4: Functions
16. Write a function that returns the maximum and minimum numbers in a list.
17. Implement a function to calculate the number of vowels in a given string.
18. Write a program to create a function that takes a list of numbers and returns a new list
with each element squared.
19. Implement a recursive function to calculate the sum of all numbers up to a given number.
20. Write a program using lambda functions to filter out all the numbers greater than 10 from
a list.
21. Create a class Book with attributes for title, author, and price, and a method to display
book details.
22. Create a class Circle with methods to calculate the area and circumference. Demonstrate
method overloading by adding a method for the diameter.
23. Create an abstract class Shape with an abstract method area(). Implement this in
subclasses Rectangle and Triangle.
24. Write a program with custom exceptions for a BankAccount class to handle cases of
invalid withdrawals (e.g., insufficient funds).
25. Write a program to demonstrate multilevel inheritene.
26. Write a program to read from one text file and copy its content into another file.
27. Create a program that writes user information (name, age, address) to a file and then
reads and displays it.
28. Demonstrate the use of the os module to rename a file and delete it afterward.
29. Create a program that reads a CSV file and displays each row in a formatted output.
30. Using NumPy, write a program to generate a 3x3 matrix of random integers and find the
maximum and minimum values.
31. Create a scatter plot using Matplotlib for two lists representing the x and y coordinates of
points.
32. Use Matplotlib to create a bar graph of student scores for five subjects and display the
title and labels.
33. Implement a program to use Numpy arrays and demonstrate basic slicing and reshaping.
34. Write a program to connect to an SQL database and insert a new record into a table and
display it.
35. Implement a basic GUI calculator using tkinter.