PYTHON PROGRAMMING QUESTIONS
PYTHON PROGRAMMING QUESTIONS
1. Write a Python program to calculate the factorial of a given number using recursion.
3. Write a Python function to find the greatest common divisor (GCD) of two numbers.
6. Write a Python program to find the largest and smallest numbers in a list.
8. Write a Python program to merge two dictionaries and print the resulting dictionary.
9. Implement a Python program to sort a list of tuples based on the second element.
String Manipulation
10. Write a Python program to count the occurrence of each character in a string.
11. Create a Python program to find all the substrings of a given string.
File Handling
12. Write a Python program to read a file and count the number of words, lines, and characters
in it.
13. Implement a Python program to copy the contents of one file to another.
14. Create a Python class Student with attributes for name, roll number, and marks in three
subjects. Write a method to calculate the average marks of the student.
Advanced Concepts
15. Write a Python program to implement a stack using a list, with operations for push, pop, and
displaying the stack.
16.
17. Write a Python program to create a database named LibraryDB and a table named Books with
columns: BookID (INT, Primary Key), Title (VARCHAR), Author (VARCHAR), and Price (FLOAT).
18. Write a Python program to insert multiple records into the Books table in LibraryDB. Use
placeholders and a list of tuples for the data.
19. Write a Python program to retrieve and display all records from the Books table, ordered by
Price in descending order.
20. Write a Python program to update the Price of a specific book in the Books table based on its
BookID, and display the updated record.