A.K.
CHILDREN ACADEMY,
RAJ NAGAR Extension, GZB
Practical file on
Computer science (083)
Session: 2024-2025
Topics covered: Python Programs
SUBMITTED TO: SUBMITTED BY:
Ms. Achla Agarwal Ummi Parthasarathi
PGT(COMP.SCI) Class: XII-A
Roll No.: 22
S. No Topic T. Sign
Write a program that performs the following
1. operations on a string:
(a)Prompt the user to input a string.
(b) Extract all the digits from the string.
(c) If there are digits in the inputted string:
Calculate and display the sum of the digits.
Also display:
The original string
The digits The sum of the digits
Write a program with a user-defined function with string
as a parameter which replaces all vowels in the string
2. with “*”
Write a python program to remove duplicates from a
list.
3. A = [10, 20, 30, 20, 10, 50, 60, 40, 80, 50, 40]
Write a Python program that generates random
4. numbers between 1 and 6 (simulates a dice)
Write a program that defines a function which will print
Fibonacci series till n passed as argument to the
5. function.
Write a Python program that defines a method to find
and display the prime numbers between 2 to N. Pass N
6. as argument to the method.
Remove all the lines that contain the character `a' in a
file and write it to another file.
7.
Write a Python program to print just the last line of a
text file "data.txt" along with total lines in a text file.
8.
Write a menu-driven program implementing user-
9. defined functions to perform different operations
onto a student.csv file having fields roll number,
name, stream and marks such as:
(a) Write a single record to CSV.
(b) Write all the records in one single go onto the
CSV.
(c) Display the contents of the CSV file.
Write a Python program that create a binary file
10. with roll number, name and marks. Input a roll
number and update the marks.
Write a program to add (PUSH), delete (POP)
and display the records using list through Stack.
11.
Write a program to display unique vowels
12. present in the given word using stack.
Write a Python program that prints the first n
13. rows of Pascal's triangle.
Write a Python program that read a text file line
14. by line and display each word separated by a #.
Write a Python program that read a text file and
15. display the number of
(a) vowels
b) consonants
(c) uppercase
(d) lowercase characters in the file.
Write a Python program that create a binary file
16. with name and roll number. Search for a given
roll number and display the name, if not found
display appropriate message.
Write a menu-driven program to demonstrate
17. four major operations performed on a table
through MYSQL-Python connectivity.
Index
Write a program that performs the following operations on a string:
(a)Prompt the user to input a string.
(b) Extract all the digits from the string.
(c) If there are digits in the inputted string:
Calculate and display the sum of the digits.
Also display:
The original string
The sum of the digits
Input:
Output:
Write a program with a user-defined function with string as a
parameter which replaces all vowels in the string with “*”
Input:
Output:
Write a python program to remove duplicates from a
list.
A = [10, 20, 30, 20, 10, 50, 60, 40, 80, 50, 40]
Input:
Output:
Write a Python program that generates random
numbers between 1 and 6 (simulates a dice)
Input:
Output:
Write a program that defines a function which will print
Fibonacci series till n passed as argument to the
function.
Input:
Output:
Write a Python program that defines a method to find and
display the prime numbers between 2 to N. Pass N as argument
to the method.
Input:
Output:
Remove all the lines that contain the character `a' in a file and
write it to another file.
Input:
Output:
Write a Python program to print just the last line of a text file
"data.txt" along with total lines in a test file
Input:
Text File:
Output:
Write a menu-driven program implementing user-defined functions to
perform different operations onto a student.csv file having fields roll
number, name, stream and marks such as:
(a) Write a single record to CSV.
(b) Write all the records in one single go onto the CSV.
(c) Display the contents of the CSV file.
Input:
Output:
Write a Python program that create a binary file with roll
number, name and marks. Input a roll number and update the
marks
Input:
Output:
Write a program to add (PUSH), delete (POP) and display the
records using list through Stack.
Input:
Output:
Write a program to display unique vowels present in the given
word using stack
Input:
Output:
Write a Python program that prints the first n rows of Pascal's
triangle.
Input:
Output:
Write a Python program that read a text file line by line and
display each word separated by a #.
Input:
Text File:
Output:
Write a Python program that read a text file and display the
number of (a) vowels (b) consonants (c) uppercase (d)
lowercase characters in the file.
Input:
Text File:
Output:
Write a Python program that create a binary file with name and
roll number. Search for a given roll number and display the
name, if not found display appropriate message
Input:
Output: