Professional Documents
Culture Documents
Session 2023-24
PYTHON
PROGRAMMING FILE
MADE BY-
NAME :ARYAN
CLASS : XII-Science
ROLL NO :________
1
Session 2023 -24
LIST OF PRACTICALS :
S.NO. AIM
1 Write a program to show entered string is a palindrome or not.
2 Write a program to show statistics of characters in the given line(to counts the
number of alphabets ,digits, uppercase, lowercase, spaces and other characters).
3 WAP to show sum of all odd numbers and even numbers from the list entered by
user.
4 Write a program to display frequencies of all the element of a list entered by user.
5 Write a program to display those string which are starting with ‘A’ from the given
list.
6 Write a program to find and display the sum of all the values which are ending with
3 from a list.
7 Write a program to show sorting of elements of a list step-by-step , using bubble
sorting technique.
8 Write a program to input total number of sections and stream name in 11th class and
display all information on the output screen.
9 Write a program to input name of ‘n’ countries and their capital and currency store, it
in a dictionary and display in tabular form also search and display for a particular
country.
10 Write a function in python, which accept a number from user to return True, if the
number is a prime number else return False. Use this function to print all prime
numbers from 1 to 100.
11 WAP to show functionality of a basic calculator using functions.
12 Write a program to enter the numbers and find Linear Search, Binary Search, Lowest
Number and Selection Sort using array code with user defined functions.
13 Write a program to find factorial of entered number using library function fact().
14 Write a program to call great func() to find greater out of entered three umbers, using
import command.
15 Write a random number generator that generates random numbers between 1 and 6
(simulates a dice). Throw the two dices for 10 times and print their total.
16 Write a program to show and count the number of words in a text file ‘DATA.TXT’
which is starting/ended with an word ‘The’, ‘the’.
17 Write a program to read data from a text file info.TXT, and display each word with
number of vowels and consonants.
18 Write a program to read data from a text file value.TXT, and display word which
have maximum/minimum characters.
2
Session 2023 -24
19 Write a program to create a text file and print the lines starting with ‘T’ or ‘P’. (Both
uppercase and lowercase).
20 Write a program to write a string in the binary file “comp.bin” and count the number
of times a character appears in the given string using a dictionary.
21 Write a program that will write a string in binary file "school.bin" and
display the words of the string in reverse order.
22 Consider a binary file “Emp.bin” containing details such as empno:
ename:salary(separator‘:’).Write a python function to display details of those
employees who are earning between 20000 and 40000.
23 Create a binary file with roll number, name and marks. Input a roll number and
update the marks.
24 Write a program to insert list data in CSV File and print it.
25 Read a CSV file (containing item no, name, rate, QOH) from hard disc and print all
the items whose rate is between Rs 500 and Rs 1000.
26 Read a CSV file from hard disc and print all the details on the screen.
27 Create a CSV file by entering user-id and password, read and search the password for
given userid.
28 Write a program to insert item on selected position in list and print the updated list.
29. Write a program to show push and pop operation using stack.
30. Julie has created a dictionary containing names and marks as key value pairs of 6
students. Write a program, with separate user defined functions to perform the
following operations:
● Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 75.
● Pop and display the content of the stack.
31. Raghav has created a vocabulary list. You need to help him create a program with
separate user defined functions to perform the following operations based on this list.
(a) Traverse the content of the list and push the entries having less than 7 characters
into a stack.
(b) Pop and display the content of the stack.
For example: If the sample content of the list is as follows:
W=[‘Elucidate’,’Haughty’,’Pacify’,’Quip’,’Rapport’,’Urbane’,’Young’,’Zenith’]
Sample output of the code should be:Pacify, Quip, Urbane,Young, Zenith
3
Session 2023 -24
32. Write a program A company having a dictionary of various Departments and Number
of Computers (PC) available as key-value pairs.Write a program, with
separate user defined functions to perform the following operations:
(a) Push the keys (name of the department) of the dictionary into the stack where the
corresponding value (number of PC) is 25 or more.
(b) Pop and display the content of the stack.
For eg: setup={“HR”:10,”QUALITY”:25,”SUPPORT”:50,
”PRODUCTION”:20,”SUPPLY”:25}
Then the output should be: QUALITY SUPPORT SUPPLY
33. Alam has a list containing 10 integers. You need to help him create a program with
separate user defined functions to perform the following operations based on this list.
● Traverse the content of the list and push the even numbers into a stack.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be: 2 98 56 34 12
34. Nandu has created a dictionary containing countries and continent as key value pairs
of 6 countries. Write a program, with separate user defined functions to perform the
following operations:
● Push the keys (name of the country) of the dictionary into a stack, where country
belongs to continent “ASIA”.
● Pop and display the content of the stack.
For example: If the sample content of the dictionary is as follows:
R={"UK":”EUROPE, "INDIA":”ASIA”, "CHINA":”ASIA”,
"EGYPT":”AFRICA”, "CUBA":”AMERICA”, "JAPAN":”ASIA”}
The output from the program should be: JAPAN CHINA INDIA
35. In MySql, Create a database named SGNPS, under this database create table named
STUDENT with admno,name,class,sec,rno,address. Insert two rows of data. Write
Python program to establish connection to database, update record with new values
for the entered admno.
36. Write a Program to show database connectivity of python with MySQL database to
perform insertion , updation , deletion and retrieval .
4
Session 2023 -24
#CODING :
5
Session 2023 -24
OUTPUT:
6
Session 2023 -24
#AIM2 : WAP to counts the number of alphabets ,digits, uppercase, lowercase, # spaces and
other characters(status of a string).
#CODING :
OUTPUT:
7
Session 2023 -24
#AIM3:WAP to show sum of all odd numbers and even numbers from the list entered by
user.
#CODING:
8
Session 2023 -24
OUTPUT:
#AIM 4 :WAP to display frequencies of all the element of a list entered by user.
#CODING :
10
Session 2023 -24
OUTPUT:
11
Session 2023 -24
#AIM 5: WAP to display those string which starts with ‘A’ from the given list.
12
Session 2023 -24
#CODING :
OUTPUT:
13
Session 2023 -24
14
Session 2023 -24
“AIM 6:WAP to find and display the sum of all the values which are ending with 3 from a
list entered by user”’
#CODING :
OUTPUT:
15
Session 2023 -24
16
Session 2023 -24
#AIM 7: Write a AIM to show sorting of elements of a list step-by-step, using bubble sorting
technique.
#CODING :
OUTPUT:
‘“AIM8 : WAP to input total number of sections and stream name in 11th class and display
all information on the output screen.”’
18
Session 2023 -24
#CODING :
OUTPUT:
19
Session 2023 -24
#AIM9: WAP to input name of ‘n’ countries and their capital and currency store, it in a
dictionary and display in tabular form also search and display for a particular country.’”
#CODING :
20
Session 2023 -24
OUTPUT:
21
Session 2023 -24
‘“AIM10 : Write a function in python, which accept a number from user to return True, if
the #number is a prime number else return False. Use this function to print all prime
numbers #from 1 to 100.
22
Session 2023 -24
#CODING :
OUTPUT:
23
Session 2023 -24
24
Session 2023 -24
CODING:
OUTPUT:
25
Session 2023 -24
CODING:
27
Session 2023 -24
28
Session 2023 -24
29
Session 2023 -24
OUTPUT:
30
Session 2023 -24
31
Session 2023 -24
32
Session 2023 -24
33
Session 2023 -24
34
Session 2023 -24
“““AIM13: Write a AIM to find factorial of entered number using library function
fact().”””
35
Session 2023 -24
OUTPUT :
36
Session 2023 -24
#AIM14 : Write a AIM to call great function to find greater out of entered three numbers,
using import command.
#CODING :
37
Session 2023 -24
OUTPUT:
38
Session 2023 -24
#AIM15 : Write a random number generator that generates random numbers between 1
#and 6 (simulates a dice). Throw the two dices for 10 times and print their total.
#CODING :
OUTPUT:
39
Session 2023 -24
40
Session 2023 -24
#AIM16 :Write a aim to show and count the numbers of words in a text file “DATA.TXT”
Which is starting/ended with an word ”the”,”The”,”My”,”my”,”He”,”he”,”’They”,”they”.
#CODING :
OUTPUT:
41
Session 2023 -24
OUTPUT:
43
Session 2023 -24
#AIM 18 : WAP to read data from a text file value.txt, and display word which have
maximum/minimum characters.
44
Session 2023 -24
#CODING :
OUTPUT:
45
Session 2023 -24
46
Session 2023 -24
““AIM 19 : Write a program to create a text file and print the lines starting with ‘T’ or ‘P’.
(Both uppercase and lowercase).’’’
#CODING :
47
Session 2023 -24
OUTPUT:
48
Session 2023 -24
#AIM 20 : Write a AIM to write a string in the binary file “comp.bin” and count the
number of times a character appears in the given string using a dictionary.
#CODING :
49
Session 2023 -24
OUTPUT:
50
Session 2023 -24
‘’‘AIM 21 : Write a program that will write a string in binary file "school.dat" and
#CODING :
51
Session 2023 -24
OUTPUT:
#CODING :
OUTPUT:
53
Session 2023 -24
54
Session 2023 -24
#AIM 23: Create a binary file with roll number, name and marks. Input a roll number and update
the marks.
#CODING :
OUTPUT:
55
Session 2023 -24
56
Session 2023 -24
#AIM 24 : Write a program to insert list data in CSV File and print it
#CODING :
57
Session 2023 -24
OUTPUT:
58
Session 2023 -24
#AIM 25: WAP to read a CSV file (containing item no, name, rate, QOH) from hard disc
and print all the items whose rate is between Rs 500 and Rs 1000.
Coding:
59
Session 2023 -24
OUTPUT:
#AIM 26 : WAP to read a CSV file from hard disc and print all the details on the screen
60
Session 2023 -24
#Coding:
OUTPUT:
61
Session 2023 -24
‘’’AIM 27 : WAP to create a CSV file by entering user-id and password, read and search the
password for given userid.’’’
62
Session 2023 -24
#CODING :
OUTPUT:
63
Session 2023 -24
‘’’AIM 28 : Write a program to insert item on selected position in list and print the updated
list.
65
Session 2023 -24
CODING:
OUTPUT:
‘’’AIM 29 : Write a program to show push and pop operation using stack.
CODING:
67
Session 2023 -24
OUTPUT:
68
Session 2023 -24
‘’’AIM 30 : Julie has created a dictionary containing names and marks as key value pairs of
6 students. Write a program, with separate user defined functions to perform the following
operations:
● Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 75.
70
Session 2023 -24
CODING:
71
Session 2023 -24
72
Session 2023 -24
73
Session 2023 -24
OUTPUT:
74
Session 2023 -24
75
Session 2023 -24
‘’’AIM 31 : Raghav has created a vocabulary list. You need to help him create a program
with separate user defined functions to perform the following operations based on this list.
(a) Traverse the content of the list and push the entries having less than 7 characters into a
stack.
(b) Pop and display the content of the stack.
For example: If the sample content of the list is as follows:
W=[‘Elucidate’,’Haughty’,’Pacify’,’Quip’,’Rapport’,’Urbane’,’Young’,’Zenith’]
Sample output of the code should be:Pacify, Quip, Urbane,Young, Zenith’’’
CODING:
76
Session 2023 -24
77
Session 2023 -24
78
Session 2023 -24
OUTPUT:
79
Session 2023 -24
80
Session 2023 -24
CODING:
81
Session 2023 -24
OUTPUT:
82
Session 2023 -24
83
Session 2023 -24
‘’’AIM 33 : Alam has a list containing 10 integers. You need to help him create a program
with separate user defined functions to perform the following operations based on this list.
● Traverse the content of the list and push the even numbers into a stack.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be: 2 98 56 34 12’’’
CODING:
84
Session 2023 -24
OUTPUT:
85
Session 2023 -24
‘’’AIM 34 : Nandu has created a dictionary containing countries and continent as key value
pairs of 6 countries. Write a program, with separate user defined functions to perform the
following operations:
● Push the keys (name of the country) of the dictionary into a stack, where country belongs
to continent “ASIA”.
● Pop and display the content of the stack.
For example: If the sample content of the dictionary is as follows:
R={"UK":”EUROPE, "INDIA":”ASIA”, "CHINA":”ASIA”,
"EGYPT":”AFRICA”, "CUBA":”AMERICA”, "JAPAN":”ASIA”}
The output from the program should be: JAPAN CHINA INDIA’’’
CODING:
86
Session 2023 -24
OUTPUT:
87
Session 2023 -24
88
Session 2023 -24
‘’’AIM 35 : In MySql, Create a database named student, under this database create table
named STUDENT with sid,sname,sage,marks,sclass,ssection. Insert one row of data. Write
Python program to establish connection to database, update record with new values for the
entered admno.’’’
CODING:
OUTPUT:
89
Session 2023 -24
90
Session 2023 -24
CODING:
91
Session 2023 -24
92
Session 2023 -24
93
Session 2023 -24
94
Session 2023 -24
OUTPUT:
95
Session 2023 -24
96
Session 2023 -24
97
Session 2023 -24
98