Class XII Computer Science
Practical Practice Questions SET-1
Section A: Python Programming
1. Write a Python program to input 10 integers in a list and print the largest and smallest elements.
2. Write a program to create a list of numbers. Replace all even numbers with their square and odd
numbers with their cube.
3. Write a program to count the frequency of each element in a list using a dictionary.
4. Write a program to store names and marks of 5 students in a dictionary and display:
* Student with highest marks
* Average marks
5. Write a function `prime(n)` that returns True if `n` is prime, otherwise False.
6. Write a function `count_vowels(s)` that returns the number of vowels in a string.
7. Write a recursive function `factorial(n)` to compute factorial of a number.
8. Write a function `fibonacci(n)` that prints first `n` Fibonacci numbers.
9. Write a program to input two numbers and divide them. Handle the exception if denominator is zero.
10. Write a program to read a number from the user. Handle exception if user enters non-numeric data.
11. Write a program to read a list of numbers and display only positive numbers. Handle the exception if
user enters invalid input.
12. Write a program to read a text file and count the number of lines, words and characters.
13. Write a program to display the longest line in a text file.
14. Write a program to count the occurrences of the word “India” in a text file.
15. Write a program to store roll number, name and marks of students in a binary file. Then read and
display all records.
16. Write a program to search for a student by roll number in a binary file.
17. Write a program to update marks of a student in a binary file.
18. Write a program to store employee data (empno, name, salary) in a CSV file.
19. Write a program to read all records from the CSV file and display employees with salary greater than
50,000.
20. Write a program to count how many employees are in each department from a CSV file.
Section B: MySQL
21. Create a database `school` and a table `student` with fields: rollno (int, primary key), name (varchar),
class (int), marks (int).
22. Alter the table `student` to add a column `phone` (varchar).
23. Remove the column `phone` from `student`.
24. Add a primary key on `rollno`.
25. Insert 5 records into `student`.
26. Update marks of a student with rollno = 3 to 95.
27. Delete all students having marks < 40.
28. Display all students sorted in descending order of marks.
29. Display name and marks of students who scored between 60 and 90.
30. Display distinct classes present in `student` table.
31. Display names of students whose name starts with ‘A’.
32. Display names of students whose marks are NULL.
33. Display names of students whose marks are NOT NULL.
34. Display records of students whose marks are either 50 or 80.
35. Display name and marks of top 3 students.
36. Display rollno, name and marks of students where marks + 5 is greater than 90.
37. Display all students where class = 12 AND marks > 60.
38. Display students where class = 11 OR marks > 80.
39. Display names of students where marks <> 75.