VISHAL INTERNATIONAL SCHOOL
Class-XII
Computer Science
Python – Practical list
Instructions for Python Practical File:
1. All programs must be written only in Python language.
2. Take a printout of each program along with:
o The program code
o The output
o Any text file or CSV file used in that program
3. Printouts should be taken on A4-size sheets only.
4. All programs must be in successfully running condition before printing.
5. The sequence of programs should be exactly as given in the practical list.
6. Do not use any special fonts. Ensure all pages have the same font and font size
(11 or 12).
7. For each program, follow this order:
o First, write the question.
o Then, write the code.
o Finally, attach the output of the program.
Sr. Program
No.
1 Write a menu-driven program to make a simple calculator for arithmetic operations.
2 Write a program that simulates the rolling of a dice using the `randrange()` function
from the `random` library.
3 Write a program for a random number generator that generates numbers between 10 and
20.
4 Write a program with a function `chkOdd()` that takes one argument (a positive integer)
and reports if the argument is odd or not.
5 Write a program with a function to write a Python introduction to a text file named
'introduction.txt'.
6 Write a program with a function to read a text file line by line and display each word
separated by “#” from 'introduction.txt'.
7 Write a program with functions to count the number of:
1) Lowercase letters
2) Uppercase letters
3) Spaces
in 'introduction.txt'.
8 Write a program to count the number of words in a text file” introduction.txt”.
9 Write a program to count and display the number of lines in a text file
“introduction.txt”.
10 Write a program to copy all the data from one text file to another.
11 Write a program to remove all the lines containing the letter “a” in a text file and write
the remaining lines into another file.
12 Write a program to store multiple integers in a binary file, then read and display them
on the screen.
13 Write a program to write a dictionary to a binary file and read the dictionary contents
back from the file.
14 Write a program to create a binary file with names and roll numbers. Search for a given
roll number and display the name; if not found, display an appropriate message.
15 Write a program to create a binary file with roll number, name, and marks. Input a roll
number and update the marks.
16 Write a program to write multiple rows to a CSV file and display the rows.
17 Write a program to create a CSV file by entering the user_id and password, then search
the password for a given user_id.
18 Write a program to implement stack operations using a list.
1)Push 2)Pop 3) peek 4)display