G.D.
GOENKA PUBLIC SCHOOL
SARITA VIHAR
COMPUTER SCIENCE
CLASS XI
Code:083
PRACTICAL FILE
(SESSION 2024-25)
SUBMITTED TO: Submitted By:
Ms. Priyanka Singhal
Ayan Computer Science
No. Name of Practical Sign of the Teacher
1. WAP to compute x n of given two integers x and n.
2. WAP for calculating simple interest.
3. WAP to accept a number from the user and display whether
it is an even number or odd number.
4. WAP to print Fibonacci series up to certain limit.
5. WAP to display prime numbers up to a certain
limit.
6. WAP to accept a number, find and display whether it’s a
Armstrong number or not.
7. WAP to accept a number and find out whether it is a perfect
number or not.
8. WAP to print the sum of the series
1+x1/1!+x2/2!+.......xn/(n)!- exponential series.
9. WAP to print the following pattern:
12
123
10. WAP to accept a string and display whether it is a
palindrome.
11. WAP that counts the number of alphabets and digits,
uppercase letters, lowercase letter, spaces and other
characters in the string entered.
12. WAP to accept a string ( a sentence) andreturns a string
having first letter of each word in capital letter.
13. WAP to remove all odd numbers from the given list
14. WAP to display second largest element of a given list.
15. WAP to display cumulative elements of a given list.
16. WAP to display frequencies of all the elements of a list.
17. WAP in Python to display those strings which are string
with ‘A’ of given list.
18. WAP in Python to find and display the sum of all the values
Ayan Computer Science
which are ending with 3 from a list.
19. WAP to shift the negative number to left and the positive
numbers to right.
20. WAP to swap the content with next value divisible by 7.
21. Write a program to input total number of sections and
stream name in 11th class and
display all information on the output screen.
22. Write a Python program to input names 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.
23. Write a programme to input 'n' names and phone numbers
to store it in a dictionary and print the phone numberof a
particular name.
24. Write a programme to input names of n employees and
their salary details like basic salary, house rent and con-
veyance allowance. Calculate the total salary of each em-
ployee and display.
25. Write a programme to input names of n countries and their
capital and currency, store it in the dictionaryand display
in tabular form. Also search for a particular country
26. Q31Program 25:WAP a menu-driven program to enter your friends’ name and
their phone numbers and store them in the dictionary as key-value pair. Per-
form following operations on dictionary:
(a) Display the name and phone number of all your friends.
(b) Add a new key-value pair in this dictionary and display the modified dic-
tionary.
(c) Delete a particular friend from the dictionary.
(d) Modify the phone number of an existing friend.
(e) Check if a friend is present in the dictionary or not.
(f) Display the dictionary in sorted order of names
27. WAP to convert number entered by the user into its corre-
sponding number in words.
Ayan Computer Science
#Practical File
1.Write a Program to compute x^n
where x and n are given integers
x=int(input("Enter a number"))
y=int(input("enter a power"))
z=x**y
print(z)
#Output
Enter a number5
enter a power4
625
2.Write a programcalculating simple
interest.
print("Simple Intrest Calculation")
Ayan Computer Science
print("Enter the following deails")
x=float(input("Enter Principle
Amount"))
y=float(input("Enter Time"))
z=float(input("Enter Rate of
Intrest"))
i=(x*y*z)/100
print("Intrest is",i)
#Output
Simple Intrest Calculation
Enter the following deails
Enter Principle Amount200
Enter Time5
Enter Rate of Intrest2.5
Intrest is 25.0
3.Write a program to accept a
number from the user and display
whether it is an even number or
odd number.
Ayan Computer Science
x=int(input("enter no:"))
if(x%2==0):
print("Even number")
else:
print("Odd number")
#Output
enter no:7
Odd number
4.Write a program to accept percentage of a
student and display grade
Percentage=float(input("Enter the percentage
:"))
if Percentage>=85:
print("Grade A")
elif Percentage>=70:
print("Grade B")
Ayan Computer Science
elif Percentage>=55:
print("Grade C")
elif Percentage>=40:
print("Grade D")
else:
print("Grade E")
#Output
Enter the percentage :59
Grade C
5.Write a program to print
Fibonacci series up to certain
limit.
i=int(input("Enter the limit"))
x=0
y=1
z=1
print("fibonacci series")
while(z<=i):
Ayan Computer Science
print(z,end=" ")
x=y
y=z
z=x+y
#Output
Enter the limit23
fibonacci series
1 2 3 5 8 13 21
6.Write a program to display prime numbers up to a
certain limit.
x=int(input("Enter limit"))
for num in range(x+1):
i=2
while i<num:
if num%i==0:
break
i+=1
else:
print("Num is a prime number")
#Output
Enter limit55
Num is a prime number
Num is a prime number
Ayan Computer Science
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
Num is a prime number
7.Write a program to accept a number,
find and display whether it’s a
Armstrong number or not.
num=int(input("Enter a 3 digit number"))
f=num
sum=0
while (f>0):
a=f%10
f=int(f/10)
sum=sum+(a**3)
if (sum==num):
print("Its an armstrong number",num)
else:
Ayan Computer Science
print("Its not an armstrong
number",num)
#Output
Enter a 3 digit number568
Its not an armstrong number 568
8.Write a program to accept a
number and find out whether it
is a perfect number or not.
i=1
s=0
num=int(input("Enter a Number"))
while i<=num:
if num%i==0:
s+=i
i=i+1
if s==num:
Ayan Computer Science
print("Its a perfect number")
else:
print("its not a perfect
number")
#Output
Enter a Number5
its not a perfect number
9.Write a program to print the
following pattern:
#1
#1 2
#1 2 3
i=1
while i<=3:
j=1
while j<=i:
print(j,end=" ")
j=j+1
Ayan Computer Science
print()
i=i+1
#Output
1
1 2
1 2 3
10.Write a program to accept a string
and display whether it is a
palindrome.
str=input("Enter a string")
l=len(str)
p=l-1
index=0
while (index<p):
if (str[index]==str[p]):
index+=1
p-=1
else:
print("Not a palindrome")
break
Ayan Computer Science
else:
print("Number is Palindrome")
#Output
Enter a string4
Number is Palindrome
str1=input("Enter a string")
n=d=c=s=u=l=o=0
for ch in str1:
if ch.isalpha():
n+=1
if ch.isupper():
u+=u
elif ch.islower():
l+=l
elif ch.isalpha():
c+=1
if ch.isdigit():
d+=1
if ch.isspace():
s+=1
else:
o+=1
print ("No. of alphabets and digits",n)
print ("No. of upper case letters",u)
print ("No. of lower case letters",l)
print ("No. of spaces",s)
print ("No. of digits",d)
print ("No. of special characters",o)
Ayan Computer Science
#Output
Enter a stringkujygvkVYCGVIUIYtiytcticyt tyfi7g9yg i 6it
fif7
No. of alphabets and digits 39
No. of upper case letters 0
No. of lower case letters 0
No. of spaces 4
No. of digits 4
No. of special characters 43
12.Write a program to accept a
string ( a sentence) and return
a string having the first letter
of each word in capital letters.
str1=input("Enter a string")
print("original string:",str1)
str2=""
x=str1.split()
for a in x:
str2+=a.capitalize()+" "
print(str2)
Ayan Computer Science
#Output
Enter a stringmy name is ruchir
original string: my name is
ruchir
My Name Is Ruchir
13.Write a program to remove all
odd numbers from the given Index
list.
def main():
L=[2,7,12,5,10,15,23]
for i in L:
if i%2==0:
L.remove(i)
print(L)
main()
#Output
Ayan Computer Science
[7, 5, 15, 23]
14.Write a program to display
the largest element of a given
list.
L=[41,6,9,13,4,23]
m=max(L)
secmax=L[0]
for i in range(1,len(L)):
if L[i]>secmax and L[i]<m:
secmax=L[i]
print(secmax)
#Output
41
Ayan Computer Science
15.Write a program to display
cumulative elements of a given
list.
list=[1,3,5,7,8]
finallist=[list[0]]
for i in range(1,len(list)):
finallist+=[finallist[i-
1]+list[i]]
print(finallist)
#Output
[1, 4, 9, 16, 24]
Ayan Computer Science
16.Write a program to display
frequencies of all the elements of a
list.
L=[3,21,5,6,3,8,21,6]
L1=[]
L2=[]
for i in L:
if i not in L2:
x=L.count(i)
L1.append(x)
L2.append(i)
print("Element","\t\t\t","Frequency")
for i in range(len(L1)):
print(L2[i],"\t\t\t",L1[i])
#Output
Element Frequency
3 2
21 2
5 1
6 2
8 1
Ayan Computer Science
17.Write a program to display those strings which
are string with ‘A’ of given list.
L=['AUSHIM','LEENA','AKHTAR','HIBA','NISHANT','AM
AR']
count=0
for i in L:
if i[0] in ('aA'):
count+=1
print(i)
print("Appearing",count,"Times")
#Output
AUSHIM
AKHTAR
AMAR
Appearing 3 Times
18.Write a program to find and
display the sum of all the
Ayan Computer Science
values which are ending with 3
from a list.
L=[33,13,92,99,3,12]
sum=0
x=len(L)
for i in range(0,x):
if type(L[i])==int:
if L[i]%10==3:
sum+=L[i]
print(sum)
#Output
49
19.Write a program to shift the negative number
to left and the positive numbers to right so
that the resultant list will look like.
#Original list [-12, 11, -13, -5, 6, -7, 5, -3,
-6]
#Output should be [11, 6, 5, -6, -3, -7, -5, -
13, -12]
Ayan Computer Science
L=[-12,11,-13,-5,6,-7,5,-6,-3]
n=len(L)
print("Original list:",L)
for i in range(n-1):
for j in range(n-i-1):
if L[j]>0:
L[j],L[j+1]=L[j+1],L[j]
print("After shifting list is:",L)
#Output
Original list: [-12, 11, -13, -5, 6, -7, 5, -6,
-3]
After shifting list is: [-12, -13, -5, -7, -6,
-3, 5, 6, 11]
20.Write a program to input total number of
sections and stream name in 11th class and
display all information on the output
screen.
classxi=dict()
n=int(input("Enter the number of sections"))
Ayan Computer Science
i=1
while i<=n:
a=input("Enter section:")
b=input("Enter the stream name")
classxi[a]=b
i+=1
print("Class",'\t',"Section",'\t',"Stream")
for i in classxi:
print("XI",'\t',a,'\t','\t',classxi[i])
#Output
Enter the number of sections2
Enter section:gdtuygflugl
Enter the stream nameftkytfktk
Enter section:ycgvvggh
Enter the stream namegvvuyvyu
Class Section Stream
XI ycgvvggh ftkytfktk
XI ycgvvggh gvvuyvyu
Q.Write a programme to input 'n' names and
phone numbers to store it in a dictionary
and print the phone numberof a particular
name.
phone=dict()
i=1
n=int(input("Enter the number of Names:"))
while i<=n:
a=input("Enter the Name")
Ayan Computer Science
b=input("Enter the Phone Number")
phone[a]=b
i+=1
l=phone.keys()
x=input("Enter name to be searched")
for i in l:
if i==x:
print(x,": phone no is:",phone[i])
break
else:
print(x,"Name not found")
Output
Enter the number of Names:4
Enter the Nameriya
Enter the Phone Number9999
Enter the Namebhargav
Enter the Phone Number0000
Enter the Namevidya
Enter the Phone Number5438
Enter the Nameafeefa
Enter the Phone Number2201
Enter name to be searchedayan
ayan Name not found
In [ ]:
Q.Write a programme to input names of n em-
ployees and their salary details like basic
salary, house rent and conveyance allowance.
Calculate the total salary of each employee
and display.
d1=dict()
i=1
Ayan Computer Science
n=int(input("Enter the number of Employ-
ees"))
while i<=n:
Nm=input("\nEnter name of the employee:")
basic=int(input("Enter Basic Salary"))
hr=int(input("Enter House Rent"))
ca=int(input("Enter Conveyance Allow-
ance"))
d1[Nm]=[basic,hr,ca]
i=i+1
l=d1.keys()
print("\nName",'\t\t',"Net Salary")
for i in l:
salary=0
z=d1[i]
for j in z:
salary=salary+j
print(i,'\t\t',salary)
Output
Enter the number of Employees4
Enter name of the employee:Nishant
Ayan Computer Science
Enter Basic Salary100000
Enter House Rent30000
Enter Conveyance Allowance5000
Enter name of the employee:Ram
Enter Basic Salary50000
Enter House Rent15000
Enter Conveyance Allowance5000
Enter name of the employee:Aushim
Enter Basic Salary200000
Enter House Rent50000
Enter Conveyance Allowance10000
Enter name of the employee:Riya
Enter Basic Salary25000
Enter House Rent2000
Enter Conveyance Allowance1000
Name Net Salary
Nishant 135000
Ram 70000
Aushim 260000
Riya 28000
In [ ]:
Q.Write a programme to input names of n
countries and their capital and currency,
store it in the dictionaryand display in
tabular form. Also search for a particular
country
d1=dict()
Ayan Computer Science
i=1
n=int(input("Enter the number of countries"))
while i<=n:
c=input("Enter the name of the country")
cap=input("Enter the capital of the country")
cur=input("Enter the currency of the country")
d1[c]=[cap,cur]
i=i+1
l=d1.keys()
print("\nCountry\t\t","Capital\t\t","Currency\t\
t")
for i in l:
z=d1[i]
print('\n',i,'\t\t',end="")
for j in z:
print(j,'\t\t',end="\t\t")
x=input("\nEnter the country to be searched:")
for i in l:
if i==x:
print("\nCountry\t\t","Capital\t\t","Cur-
rency\t\t")
z=d1[i]
print('\n',i,'\t\t',end="")
for j in z:
print(j,'\t\t',end="\t\t")
break
Output
Enter the number of countries5
Enter the name of the country: Australia
Enter the capital of the country: Vienna
Ayan Computer Science
Enter the currency of the country: Euro
Enter the name of the country: China
Enter the capital of the country: Beijing
Enter the currency of the country: Yuan
Enter the name of the country: India
Enter the capital of the country: Delhi
Enter the currency of the country: Rupees
Enter the name of the country: France
Enter the capital of the country: Paris
Enter the currency of the country: Euro
Enter the name of the country: United Kingdom
Enter the capital of the country: London
Enter the currency of the country: Pound
Country Capital Currency
Australia Vienna Euro
China Beijing Yuan
India Delhi Rupees
France Paris Euro
United Kingdom London Pound
Enter the country to be searched:India
Country Capital Currency
India Delhi Rupees
Q.WAP a menu-driven program to enter your friends’ name and their phone numbers and store them in
the dictionary as key-value pair. Perform following operations on dictionary:
(a) Display the name and phone number of all your friends.
(b) Add a new key-value pair in this dictionary and display the modified dictionary.
(c) Delete a particular friend from the dictionary.
Ayan Computer Science
(d) Modify the phone number of an existing friend.
(e) Check if a friend is present in the dictionary or not.
(f) Display the dictionary in sorted order of names.
n=int(input("No. of friends:"))
dict={}
for i in range(n):
name=input("Name:")
ph_no=int(input("Phone no.:"))
dict[name]=ph_no
while True:
print("MENU\n\
1.Display name & Phone number\n\
2.Add a new name\n\
3.Delete a name\n\
4.Modify an existing number\n\
5.Check if a name is there\n\
6.Display dictionary in sorted order\n\
7.Exit")
ch=int(input("Enter your choice(1-6):"))
if ch==1:
for i in dict:
print(i,"-",dict[i])
elif ch==2:
name1=input("Enter name:")
ph_no1=int(input("Enter phone number:"))
dict[name1]=ph_no1
print("Modified dictionary:", dict)
elif ch==3:
name1=input("Name of friend to be deleted:")
dict.pop(name1)
print("Modified dictionary:", dict)
elif ch==4:
name1=input("Name of friend:")
ph_no1=int(input("New phone number:"))
dict[name1]=ph_no1
elif ch==5:
name1=input("Name of friend:")
if name1 in dict:
print("Friend is in dicionary")
else:
print("Friend is not in dictonary")
elif ch==6:
D=dict
dict1=sorted(D.items())
print("Modified dictionary", dict1)
elif ch==7:
break
else:
print("Invalid choice")
Ayan Computer Science
Output
MENU
1.Display name & Phone number
2.Add a new name
3.Delete a name
4.Modify an existing number
5.Check if a name is there
6.Display dictionary in sorted order
7.Exit
Ayush – 9870
Rohit - 8679
Anil - 6543
Hari - 3240
MENU
1.Display name & Phone number
2.Add a new name
3.Delete a name
4.Modify an existing number
5.Check if a name is there
6.Display dictionary in sorted order
7.Exit
MENU
1.Display name & Phone number
2.Add a new name
3.Delete a name
4.Modify an existing number
5.Check if a name is there
6.Display dictionary in sorted order
7.Exit
Ayush - 9870
Rohit - 8679
Anil - 7658
Hari - 3240
MENU
1.Display name & Phone number
2.Add a new name
3.Delete a name
4.Modify an existing number
5.Check if a name is there
6.Display dictionary in sorted order
7.Exit
Enter your choice(1-6):7
Ayan Computer Science
Q.WAP to convert number entered by the user into
its corresponding number in words.
Number_Names={0:"Zero",1:"One",2:"Two",3:"Three",
4:"Four",5:"Five",6:"Six",7:"Seven",8:"Eight",9:"
Nine"}
num=input("Enter any number:")
result=""
for ch in num:
key=int(ch)
value=Number_Names[key]
result+=" "+value
print("The number is:",num)
print("The Number name is:",result)
Output
Enter any number:23
The number is: 23
The Number name is: Two Three
Ayan Computer Science