ASTER PUBLIC SCHOOL, KP5
COMPUTER PRACTICAL WORKSHEET
CLASS 12
COMPUTER SCIENCE(083)
S. NO. PRACTICAL
1. Write a user defined function countvowels() in Python to
count and display the number of vowels in a text file
“data.txt”.
2. Following fields are part of student table:
RollNo – integer
Name – string
Class – integer
Marks – integer
create a table in Mysql.
3. A binary file “employee.dat” has structure [Empid, EName,
Designation ].
a) Write a user defined function Create() to input data for a
record and add it to employee.dat .
b) Write a user defined function Display() in Python to
display those records from “employee.dat” where Empid is
more than 101.
4. Write a menu drive program to perform following operations into a
binary file shoes.dat.
Add record
Display records
Search record
Exit
The structure of file content is: [s_id, name, brand, type, price]
5. Read a text file line by line and display each word separated by a #.
Read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.
Remove all the lines that contain the character ‘a’ in a file and write
it to another file.
6. Create a binary file with the name and roll number. Search for a
given roll number and display the name, if not found display the
appropriate message.
Create a binary file with roll number, name, and marks. Input a roll
number and update the marks.
7. Write a random number generator that generates random numbers
between 1 and 6 (simulates a dice).
8. Create a student table and insert data. Implement the following SQL
commands on the student table:
ALTER table to add new attributes / modify data type/drop attribute
UPDATE table to modify data
ORDER By to display data in ascending/descending order
DELETE to remove tuple(s).
9. Write a Python program to accept a list as a function parameter and
raise the IndexError exception.
10. Write a program to accept the number of days and display
appropriate weeks in an integer. Display an appropriate error
message through multiple exception handling including the finally
clause.
11. Programs based on data file handling text files
Create a text file “intro.txt” in Python and ask the user to write a
single line of text by user input.
12. Write a program to know the cursor position and print the text
according to the below-given specifications:
Print the initial position
Move the cursor to 4th position
Display the next 5 characters
Move the cursor to the next 10 characters
Print the current cursor position
Print the next 10 characters from the current cursor position
13.
Short Programs
Program 1: Write a python program to implement a stack using a list
data structure.
Program 2:Write a program to find whether an inputted number is
perfect or not.
Program 3: Write a Program to check if the entered number is
Armstrong or not.
Program 4: Write a Program to find factorial of the entered number.
Program 5: Write a Program to enter the number of terms and to
print the Fibonacci Series.
Program 6: Write a Program to enter the string and to check if it’s
palindrome or not using loop.
Program 7: Write a program that generates a series using a function
while takes first and last values of the series and then generates four
terms that are equidistant e.g., if two number passed are 1 and 7
then function returns 1 3 5 7