CS Prctical File Class XI-2024-25
CS Prctical File Class XI-2024-25
Pr. No
1 Write a python program to input a welcome message and display it.
2 Write a python program to input two numbers and display the larger / smaller number.
3 Write a python program to input three numbers and display the largest /smallest number.
5 Write a program to input the value of x and n and print the sum of the following series:
a. 1 + x2 + x3 + ... + xn
b. x - x2/2! + x3/3! - x4/4! + x5/5! - x6/6!
6 Write a program to determine whether a number is a perfect number, an
Armstrong number or a palindrome.
7 Write a program to input a number and check if the number is a prime or composite number.
1
13 Write a program to input a list of numbers and swap elements at the even location with the elements
at the odd location.
14 Write a program to input a list of number and interchange first element to last element.
15 Write a program to create a tuple with user input and search for given element.
16 Write a program to create tuple with user input and display the square of numbers divisible by 3
and display cube of numbers divisible by 5.
17 Write a menu driven program to do the following using a dictionary.
1. Display Contacts
2. Add Contact
3. Delete a Contact
4. Change a phone number
5. Search Contact
6. Exit
18 Write a program to Create a dictionary with the roll number, name and marks of n students in a class
and display the names of students who have scored marks above 75.
19 Write a program to create a dictionary and store salesman name as a key and sales of 3 months as
values. Give the bonus to the salesman according to the given criteria:
1. Total Sales < 10K – No Bonus
2. Total Sales 10K to 20K – 5%
3. Total Sales 21K to 30K – 8%
4. Total Sales 31K to 40K – 10%
20 Write a program to enter a team name, wins and losses of a team. Store them into a dictionary where
teams names are key and winds and losses are values stored as a list. Do the following based on the
dictionary created above:
• Find out the team’s winning percentage by their names
• Display the no. of games won by each team in a list
• Display the no. of games lost by each team in a list
Ex.No:- 1
PROGRAM TO INPUT A WELCOME MESSAGE AND DISPLAY IT
Date:-
Aim:
Write a Python program to input a welcome message and display it.
Coding:
wl_msg = input(“Enter the welcome message:”)
print(wl_msg)
Output: Result:-
Aim:
Write a python program to input two numbers and display the larger / smaller number.
Coding:
Result:-
The expected output has been achieved.
3
Ex.No :- 3
PROGRAM TO INPUT THREE NUMBERS AND DISPLAY
THE LARGEST / SMALLEST NUMBER
Date:-
Aim:
Write a python program to input three numbers and display the largest / smallest number.
Coding:
Output:
Result:-
The expected output has been achieved.
4
Ex.No:- 4
PROGRAM TO CALCULATE PERIMETER/CIRCUMFERENCE AND
AREA OF SHAPES
Date:-
Aim:
Generate the following patterns using nested loop.
Coding:
Output:
Result:-
The expected output has been achieved.
5
Ex.No:- 5
PROGRAM TO CALCULATESIMPLE ANDCOMPOUND INTEREST
Date:-
Aim:
Write a program to input the value of x and n and print the sum of the following series:
Coding:
6
Result:-
7
Ex.No:- 6
PROGRAM TO DETERMINE WHETHER A NUMBER IS A
PERFECT NUMBER, AN ARMSTRONG NUMBER OR A PALINDROME.
Date:-
Aim:
Write a program to determine whether a number is a perfect number, an Armstrong
number or a palindrome.
Coding:
8
rev = rev *10 + d
n = n//10
if temp == rev :
print( temp,"is palindrome number")
else :
print( temp, "is not palindrome number")
Output:
Result:-
-----------------------------------------------------------------------------------
9
Ex.No:- 7
PROGRAM TO CHECK IF THE NUMBER IS A PRIME OR COMPOSITE
Date:-
Aim:
Write a program to input a number and check if the number is a prime or composite number.
Coding:
Output:
Result:-
10
Ex.No:- 8
PROGRAM TO DISPLAY THE FIBONACCI SERIES
Date:-
Aim:
Coding:
nterms = int(input("Enter no. of terms to display: "))
n1, n2 = 0, 1
count = 0
if nterms <= 0:
elif nterms == 1:
else:
print("Fibonacci sequence:")
print(n1)
nth = n1 + n2
n1 = n2
n2= nth
count += 1
Output:
11
Result:- The expected output has been achieved.
12
Ex.No:- 9
PROGRAM TO FIND GCD AND LCM OF TWO NUMBERS
Date:-
Aim:
Write a python program to compute the greatest common divisor and least common
multiple oftwo integers.
Coding:
Output:
Result:-
Aim:
Write a program to count and display the number of vowels, consonants, uppercase,
lower case characters in string.
13
Coding:
Output:
Result:-
Ex.No:- 11
PROGRAM TOIMPLEMENT LIST MANIPULATION
Date:-
Aim:
Write a menu driven program for list manipulation. Display menu as:
1. Add a record
2. View record
3. Delete Record
4. Modify record
5. Exit
14
Coding:
l=[]
while True:
print('''1. Add a record
2. View record
3. Delete Record
4. Modify record
5. Exit''')
ch=int(input("Enter your choice:"))
if ch==1:
v=int(input("Enter value to add a record:"))
l.append(v)
print("Record Added...")
print("List after insertion:",l)
elif ch==2:
print(l)
elif ch==3:
n=int(input("Enter the value to delete:"))
l.remove(n)
print("Record Deleted...")
print("List after deletion:",l)
elif ch==4:
i=int(input("Enter position to modify the value:"))
nv=int(input("Enter new value to modify:"))
l[i]=nv
print("Record Modified...")
print("List after modification")
elif ch==5:
print("Thank you! Good Bye")
break
15
Output:
Result:-
l=[11,32,5,43,22,98,67,44]
while True:
16
print(''
1. Maximum
2. Minimum
3. Sum
4. Sorting (Ascending)
5. Sorting (Descending)
6. Exit ''')
ch=int(input("Enter your choice:"))
if ch==1:
print("Maximum:",max(l))
elif ch==2:
print("Minimum:",min(l))
elif ch==3:
print("Sum:",sum(l))
elif ch==4:
l.sort()
print("Sorted list(Ascending):",l)
elif ch==5:
l.sort(reverse=True)
print("Sorted List(Descending:)",l)
elif ch==6:
print("Thank you! Good Bye")
break
Output:
17
Result:-
18
Ex.No:- 13
PROGRAM TO IMPLEMENT SWAPPING IN LIST
Date:-
Aim:
Write a program to input a list of numbers and swap elements at the even location with the
elements at the odd location.
Coding:
Result:-
Aim:
Write a program to input a list of number and interchange first element to last element.
Coding:
Result:-
Aim:
Write a program to create a tuple with user input and search for given element.
Coding:
t=eval(input("Enter tuple here:"))
n=int(input("Enter element to search:"))
if n in t:
print("Found:",n)
else:
print("Tuple doesn't contain ",n)
Output:
Result:-
Aim:
20
Write a program to create tuple with user input and display the square of numbers divisible
by 3and display cube of numbers divisible by 5.
Coding:
Result:-
Ex.No:- 17
MENU DRIVEN PROGRAM TO IMPLEMENT DICTIONARY OPERATIONS
Date:-
Aim:
22
print("Search Contact")
n=input("Enter name to search:")
if n in d:
print("Record Found...",d[n])
else:
print("Record not found...")
elif ch==6:
print("Quitting from App....")
input("Press Enter to Exit...")
break
Output:
23
Result:-
Ex.No:- 18
PROGRAM TO CREATE REPORT USING A DICTIONARY
Date:-
Aim:
Write a program to create a dictionary with the roll number, name and marks of n students
in aclass and display the names of students who have scored marks above 75.
Coding:
d={1:['Rudra',99],2:['Rushi',98],3:['Prakash',65],4:['Jay',84]}
for i in d:
if d[i][1]>75:
Output:
Result:-
Date:-
Aim:
Write a program to create a dictionary and store salesman name as a key and sales of 3
months asvalues. Give the bonus to the salesman according to the given criteria:
• Total Sales < 1K – No Bonus
• Total Sales 1K to 2K – 5%
• Total Sales 2.1K to 3K – 8%
• Total Sales 3.1K to 4K – 10%
24
• Total Sales >4K – 12%
Coding:
d={'Rudra':[199,180,540],'Rushi':[543,876,453],'Preet':[650,987,123],'Jay':[284,456,321]}
bonus=0
for i in d:
d[i]=sum(d[i])
for i in d:
if d[i]<1000:
d[i]=0
elif d[i]>=1000 and d[i]<=2000:
d[i]=d[i]*0.05
elif d[i]>=2001 and d[i]<=3000:
d[i]=d[i]*0.08
elif d[i]>=3001 and d[i]<=4000:
d[i]=d[i]*0.1
elif d[i]>=4001:
d[i]=d[i]*0.12
print("Bonus for salesman:")
for i in d:
print(i,"\t: %.2f"%d[i])
Output:
Result:-
Ex.No:- 20
CREATION OF DICTIONARY TO ANALYSE THE DATA
Date:-
Aim:
Write a program to enter a team name, wins and losses of a team. Store them into a
dictionary where teams names are key, wins and losses are values stored as a list. Do the
following based on the dictionary created above:
• Find out the team’s winning percentage by their names
• Display the no. of games won by each team in a list
• Display the no. of games lost by each team in a list
Coding:
25
di ={}
l_win = []
l_rec = []
while True :
t_name = input ("Enter name of team (q for quit): ")
if t_name in 'Qq' :
print()
break
else :
win = int (input("Enter the no.of win match: "))
loss = int(input("Enter the no.of loss match: "))
di [ t_name ] = [ win , loss ]
l_win += [ win ]
if win > 0 :
l_rec += [ t_name ]
n = input ("Enter name of team for winning percentage: ")
wp=di[n][0] *100 / (di[n][0] + di[n][1] )
print ("Winning percentage:%.2f"%wp)
print("Winning list of all team = ",l_win)
print("Team who has winning records are ",l_rec)
------------------------------------------------------------------------------------------
Output:
26
Result:-
27