Professional Documents
Culture Documents
CLASS XI
COMPUTER SCIENCE RECORD
2022 - 2023
SRIMATHI SUNDARAVALLI MEMORIAL SCHOOL
NEW PERUNGALATHUR, CHENNAI - 600 063
BONAFIDE CERTIFICATE
guidance.
8. TRIANGLE PATTERN - I 10
9. TRIANGLE PATTERN – II 13
AIM:
SOURCE CODE:
INPUT/OUTPUT:
RESULT:
Page 1 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
INPUT/OUTPUT:
RESULT:
Thus the program is executed successfully.
Page 2 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
INPUT/OUTPUT:
RESULT:
Thus the program is executed successfully.
Page 3 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
ch=0
while(ch!=5):
print("1. Square \n2. Rectangle \n3. Triangle \n4. Circle \n5. Exit")
ch=int(input("Enter Ur Choice"))
if(ch==1):
s=int(input("Enter the value of side:"))
a=s*s
print("Area of the Square:",a)
elif(ch==2):
l=int(input("Enter the value of length:"))
b=int(input("Enter the value of breadth:"))
a=l*b
print("Area of the Rectangle:",a)
elif(ch==3):
b=int(input("Enter the value of base:"))
h=int(input("Enter the value of height:"))
a=1/2*b*h
print("Area of the Triangle:",a)
elif(ch==4):
r=float(input("Enter the value of radius:"))
a=3.14*r*r
print("Area of the Circle:",a)
elif(ch==5):
print("Thank You !!!!")
else:
print("Enter the valid choice !!!!!")
Page 4 of 56
SSM SCHOOL PROGRAM MANUAL
INPUT/OUTPUT:
1. Square
2. Rectangle
3. Triangle
4. Circle
5. Exit
Enter Ur Choice1
Enter the value of side:5
Area of the Square: 25
Enter Ur Choice2
Enter the value of length:3
Enter the value of breadth:6
Area of the Rectangle: 18
Enter Ur Choice3
Enter the value of base:4
Enter the value of height:5
Area of the Triangle: 10.0
Enter Ur Choice4
Enter the value of radius:100
Area of the Circle: 31400.0
Enter Ur Choice5
Thank You!!!!
RESULT:
DATE:
AIM:
s=x/1!+x/2!+x/3!+ ……..+x/n!
SOURCE CODE:
INPUT/OUTPUT:
RESULT:
DATE:
AIM:
SOURCE CODE:
INPUT/OUTPUT:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
RESULT:
Page 7 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
Page 8 of 56
SSM SCHOOL PROGRAM MANUAL
INPUT/OUTPUT:
RESULT:
Page 9 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
ch=0
while(ch!=6):
print("\n1.Horizontal \n2.Vertical \n3.Continous
\n4.Alpha(Left Align) \n5.Aplha(Right Align) \n6.Exit")
ch=int(input("Enter Ur Choice: "))
if(ch==1):
n=int(input("Enter the no of Steps: "))
for i in range(1,n+1):
for j in range(1,i+1):
print(i, end=" ")
print()
elif(ch==2):
n=int(input("Enter the no of Steps: "))
for i in range(1,n+1):
for j in range(1,i+1):
print(j,end=" ")
print()
elif(ch==3):
k=1
n=int(input("Enter the no of Steps: "))
for i in range(1,n+1):
for j in range(1,i+1):
print(k, end=" ")
k=k+1
print()
elif(ch==4):
n=int(input("Enter the no of Steps(Left Align): "))
for i in range(n):
c=65
Page 10 of 56
SSM SCHOOL PROGRAM MANUAL
for j in range(i+1):
print(chr(c),end="")
c=c+1
print()
elif(ch==5):
n=int(input("Enter the no of Steps(Right Align): "))
for i in range(n):
c=65
for k in range(i,n-1):
print(end=" ")
for j in range(i+1):
print(chr(c),end="")
c=c+1
print()
elif(ch==6):
print("Thank You !!!")
else:
print("Enter the valid choice between 1 and 6")
INPUT/OUTPUT:
1.Horizontal
2.Vertical
3.Continous
4.Alpha(Left Align)
5.Aplha(Right Align)
6.Exit
Enter Ur Choice: 1
Enter the no of Steps: 5
1
22
333
4444
55555
Enter Ur Choice: 2
Enter the no of Steps: 5
1
12
123
1234
12345
Page 11 of 56
SSM SCHOOL PROGRAM MANUAL
Enter Ur Choice: 3
Enter the no of Steps: 5
1
23
456
7 8 9 10
11 12 13 14 15
Enter Ur Choice: 4
Enter the no of Steps(Left Align): 5
A
AB
ABC
ABCD
ABCDE
Enter Ur Choice: 5
Enter the no of Steps(Right Align): 5
A
AB
ABC
ABCD
ABCDE
Enter Ur Choice: 6
ThankYou!!!
RESULT:
DATE:
AIM:
SOURCE CODE:
ch=0
while(ch!=6):
print("\n1.Pyramid \n2.Inverted Pyramid \n3.Hollow Pyramid
\n4.Inverted Hollow Pyramid \n5.Exit")
ch=int(input("Enter Ur Choice: "))
if(ch==1):
n=int(input("Enter the no of Steps: "))
for i in range(1,n+1):
for k in range(i,n):
print(end=" ")
for j in range(2*i-1):
print("*",end="")
print()
elif(ch==2):
n=int(input("Enter the no of Steps: "))
for i in range(n,-1,-1):
for k in range(i,n):
print(end=" ")
for j in range(2*i-1):
print("*",end="")
print()
elif(ch==3):
n=int(input("Enter the no of Steps: "))
for i in range(1,n+1):
for k in range(i,n):
print(end=" ")
for j in range(2*i-1):
if(j==0 or j==2*i-2 or i==n):
print("*",end="")
Page 13 of 56
SSM SCHOOL PROGRAM MANUAL
else:
print(end=" ")
print()
elif(ch==4):
n=int(input("Enter the no of Steps: "))
for i in range(n,-1,-1):
for k in range(i,n):
print(end=" ")
for j in range(2*i-1):
if(j==0 or j==2*i-2 or i==n):
print("*",end="")
else:
print(end=" ")
print()
elif(ch==5):
print("Thank You !!!")
else:
print("Enter the valid choice between 1 and 6")
INPUT/OUTPUT:
1.Pyramid
2.Inverted Pyramid
3.Hollow Pyramid
4.Inverted Hollow Pyramid
5.Exit
Enter Ur Choice: 1
Enter the no of Steps: 5
*
***
*****
*******
*********
Enter Ur Choice: 2
Enter the no of Steps: 5
*********
*******
*****
***
*
Page 14 of 56
SSM SCHOOL PROGRAM MANUAL
Enter Ur Choice: 3
Enter the no of Steps: 5
*
* *
* *
* *
*********
1.Pyramid
2.Inverted Pyramid
3.Hollow Pyramid
4.Inverted Hollow Pyramid
5.Exit
Enter Ur Choice: 4
Enter the no of Steps: 5
*********
* *
* *
**
*
Enter Ur Choice: 5
Thank You!!!
RESULT:
Page 15 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
s3=""
s4=""
ch=0
while(ch!=6):
print("\n1.Length \n2.Copy \n3.Concat \n4.Reverse
\n5.Compare\n6.Exit")
ch=int(input("Enter Ur Choice: "))
if(ch==1):
s1=input("Enter String1: ")
length=0
for i in s1:
length+=1
print("\n Length of the String: ",length)
elif(ch==2):
s1=input("Enter String1: ")
for i in s1:
s3+=i
print("String Copied into S3 from S1:",s3)
elif(ch==3):
s1=input("Enter String1: ")
s2=input("Enter String2: ")
for i in s2:
s1+=i
print("String Concat of S1 and S2 in s1:",S1)
elif(ch==4):
s1=input("Enter String1: ")
length=0
Page 16 of 56
SSM SCHOOL PROGRAM MANUAL
for i in s1:
length+=1
for i in range(length-1,-1,-1):
s4+=s1[i]
print("Reversed String in S4: ",s4)
elif(ch==5):
flag=0
s1=input("Enter String1: ")
s2=input("Enter String2: ")
length1=0
for i in s1:
length1+=1
length2=0
for i in s2:
length2+=1
if(length1==length2):
for i in range(length1):
if(s1[i]!=s2[i]):
flag=1
break
if(flag==0):
print("Strings are Equal")
else:
print("Strings are not Equal")
else:
print("Strings are not Equal")
elif(ch==6):
print("Thank You :)")
else:
print("Enter a valid choice bw 1 and 6")
INPUT/OUTPUT:
1.Length
2.Copy
3.Concat
4.Reverse
5.Compare
6.Exit
Enter Ur Choice: 1
Enter String1: Chennai
Page 17 of 56
SSM SCHOOL PROGRAM MANUAL
Enter Ur Choice: 2
Enter String1: Super Kings
String Copied into S3 from S1: Super Kings
Enter Ur Choice: 3
Enter String1: Chennai
Enter String2: Super Kings
String Concat of S1 and S2 in S1: ChennaiSuper Kings
Enter Ur Choice: 4
Enter String1: CSK
Reversed String in S4: KSC
Enter Ur Choice: 5
Enter String1: CSK
Enter String2: MI
Strings are not Equal
Enter Ur Choice: 6
Thank You :)
RESULT:
Thus the program is executed successfully.
Page 18 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
for i in range(len(str1)):
if(str1[i]>='0' and str1[i]<='9'):
d+=1
elif((str1[i]>='a' and str1[i]<='z') or (str1[i]>='A' and str1[i]<='Z')):
if(str1[i]>='A' and str1[i]<='Z'):
u+=1
if str1[i] in vowel:
v+=1
elif(str1[i]==' '):
w+=1
else:
s+=1
INPUT/OUTPUT:
Page 19 of 56
SSM SCHOOL PROGRAM MANUAL
RESULT:
Page 20 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
while True:
if ch==1:
count=0
for i in s:
if i==" ":
count+=1
elif ch==2:
count=0
vowels="AEIOUaeiou"
for i in s:
if i in vowels:
count+=1
elif ch==3:
count=0
Page 21 of 56
SSM SCHOOL PROGRAM MANUAL
for i in s:
count+=1
elif ch==4:
count=0
for i in s:
count+=1
elif ch==5:
count=0
c=0
for i in s:
c+=1
else:
count+=1
elif ch==6:
print("Thank you!")
else:
print("Invalid choice")
Page 22 of 56
SSM SCHOOL PROGRAM MANUAL
INPUT/OUTPUT:
enter the string: Today 27/05/2022 is the hottest day I have ever seen!!!
1.Number of words
2.Number of vowels
4.Number of digits
6.Exit
Thank you!
Invalid choice
RESULT:
Page 23 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
# Insert by Position
e=int(input("Enter an elem to be inserted: "))
x=int(input("Enter a position to insert the new ele: "))
for i in range(n):
if(x-1==i):
for j in range(n,i-1,-1):
oned_list[j]=oned_list[j-1]
oned_list[i]=e
n=n+1
break
print()
print("New Array after insertion: ",end="")
for size in range(n):
print(oned_list[size],end=" ")
Page 24 of 56
SSM SCHOOL PROGRAM MANUAL
# Delete by Element
x=int(input("\n Enter an elem to be deleted: "))
for i in range(n):
if(x==oned_list[i]):
print(oned_list[i]," deleted")
s=i
for j in range(s,n-1):
oned_list[j]=oned_list[j+1]
n=n-1
print()
INPUT/OUTPUT:
RESULT:
Thus the program is executed successfully.
Page 25 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
if(ch==1):
maxi=L[0]
for i in range(1,n):
if(maxi<L[i]):
maxi=L[i]
print("Max in the list: ",maxi)
elif(ch==2):
mini=L[0]
for i in range(1,n):
if(mini>L[i]):
mini=L[i]
print("Min in the list: ",mini)
elif(ch==3):
for i in range(0,n):
for j in range(i+1,n):
if(L[i]>L[j]):
t=L[i]
L[i]=L[j]
L[j]=t
print("Sorted List - Ascending")
Page 26 of 56
SSM SCHOOL PROGRAM MANUAL
for i in range(0,n):
print (L[i],end=" ")
elif(ch==4):
for i in range(0,n):
for j in range(i+1,n):
if(L[i]<L[j]):
t=L[i]
L[i]=L[j]
L[j]=t
print("Sorted List - Descending")
for i in range(0,n):
print (L[i],end=" ")
elif(ch==5):
print("Thank You")
exit()
else:
print("Enter a valid choice bw 1 and 5”)
INPUT/OUTPUT:
1.Max
2.Min
3.Sort Asc
4.Sort Desc
5.Exit
Enter ur choice: 1
Max in the list: 8
Enter ur choice: 2
Min in the list: 1
Enter ur choice: 3
Page 27 of 56
SSM SCHOOL PROGRAM MANUAL
Enter ur choice: 4
Sorted List - Descending
86421
Enter ur choice: 5
Thank You
RESULT:
Thus the program is executed successfully.
Page 28 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
# Matrix Addition
Page 29 of 56
SSM SCHOOL PROGRAM MANUAL
# Matrix Multiplication
if(c1==r2):
print("Multiplication of Mat A and Mat B")
for i in range(r1):
for j in range(c2):
p=0
for k in range(r2):
p+=A[i][k]*B[k][j]
print(p,end=" ")
print("")
else:
print("Mat Multiplication not possible between A and B")
INPUT/OUTPUT:
Page 30 of 56
SSM SCHOOL PROGRAM MANUAL
RESULT:
Thus the program is executed successfully.
Page 31 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
for i in range(row_num):
for j in range(col_num):
print("a[",i,"][",j,"]: ",end="")
x = int(input())
multi_list[i][j]= x
print(multi_list[row][col],end=" ")
else:
print(end=" ")
print("")
for i in range(col_num):
for j in range(row_num):
cols[i]+=multi_list[j][i]
print("-------------------------")
for i in range(col_num):
print(cols[i],end="\t")
print()
print("-------------------------")
INPUT/OUTPUT:
789
Diagonal Elements
13
5
79
RESULT:
Thus the program is executed successfully.
Page 34 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
if(ch==1):
print("No.of Overs: ",len(tup1))
elif(ch==2):
print("Enter the Starting and the Ending over:")
s, e =int(input()), int(input())
print("Slicing of Score Card: ")
print(tup1[s-1:e])
elif(ch==3):
tup2=eval(input("Enter few more overs score: "))
tup1=tup1+tup2
print("New Score Card: ",tup1)
elif(ch==4):
print("\t IN Operator")
print("Runs in the Scorecard: ",tup1)
x=int(input("Enter the runs to be searched: "))
if x in tup1:
print("Runs Present in the Over: ",tup1.index(x)+1)
else:
print("Runs Not Present in the Scorecard!!")
Page 35 of 56
SSM SCHOOL PROGRAM MANUAL
elif(ch==5):
print("Elements in tup1: ",tup1)
x=int(input("Enter the runs: "))
print(x,"runs present in the score card",tup1.count(x),"time(s)")
elif(ch==6):
print("Thank You!!")
else:
print("Enter the Valid Choice!!!")
INPUT/OUTPUT:
Tuple Operations
5.Count
6.Exit
Enter Ur Choice: 1
No.of Overs: 5
Enter Ur Choice: 2
24
Page 36 of 56
SSM SCHOOL PROGRAM MANUAL
(4, 5, 2)
Enter Ur Choice: 3
Enter Ur Choice: 4
IN Operator
NOT IN Operator
Enter Ur Choice: 5
Enter Ur Choice: 6
Thank You!!
RESULT:
Thus the program is executed successfully.
Page 37 of 56
SSM SCHOOL PROGRAM MANUAL
PROBLEM STATEMENT:
Write a Python program to perform Tuple operations such as finding the
minimum, maximum and sum of the elements of the tuple and sorting the
Tuple by converting it into a list.
AIM:
SOURCE CODE:
ch=0
t = eval(input("Enter values for a tuple:"))
print("The tuple is :",t)
max_val = 0
min_val = t[0]
while ch!=5:
print("\n1. Maximum Value \n2. Minimum Value \n3. Sum of the
Values \n4. Sorting the values in tuple \n5. Exit")
ch=int(input("Enter you choice:"))
if ch==1:
for i in range(len(t)):
if max_val< t[i]:
max_val = t[i]
print("Maximum =",max_val)
elifch==2:
for i in range(1,len(t)):
if min_val> t[i]:
min_val = t[i]
print("Minimum =",min_val)
Page 38 of 56
SSM SCHOOL PROGRAM MANUAL
elifch==3:
s=0
for i in range(len(t)):
s+=t[i]
print("Sum of the values:",s)
elifch==4:
l=list(t)
l.sort()
print('Tuple Before Sorting: ',t)
t=tuple(l)
print("Tuple After Sorting:",t)
elifch==5:
print("Thank you!!!")
break
else:
print('Enter the option between 1 and 5')
INPUT/OUTPUT:
Enter values for a tuple:(23,43,12,64,33,76,47,88,55)
The tuple is : (23, 43, 12, 64, 33, 76, 47, 88, 55)
1. Maximum Value
2. Minimum Value
3. Sum of the Values
4. Sorting the values in tuple
5. Exit
Enter you choice:1
Maximum = 88
1. Maximum Value
2. Minimum Value
3. Sum of the Values
4. Sorting the values in tuple
Page 39 of 56
SSM SCHOOL PROGRAM MANUAL
5. Exit
Enter you choice:2
Minimum = 12
1. Maximum Value
2. Minimum Value
3. Sum of the Values
4. Sorting the values in tuple
5. Exit
Enter you choice:3
Sum of the values: 441
1. Maximum Value
2. Minimum Value
3. Sum of the Values
4. Sorting the values in tuple
5. Exit
Enter you choice:4
Tuple Before Sorting: (23, 43, 12, 64, 33, 76, 47, 88, 55)
Tuple After Sorting: (12, 23, 33, 43, 47, 55, 64, 76, 88)
1. Maximum Value
2. Minimum Value
3. Sum of the Values
4. Sorting the values in tuple
5. Exit
Enter you choice:5
Thank you!!!
RESULT:
Thus, the program is executed successfully.
Page 40 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
prod=dict()
n=int(input("Enter the no.of products: "))
i=1
while i<=n:
pname=input("Enter the product name: ")
pri=float(input("Enter the Price: "))
prod[pname]=pri
i=i+1
ch=0
while ch!=5:
print("1.Append \n2.Update \n3.Delete \n4.Display all \n5.Exit")
ch=int(input("Enter Ur Choice: "))
if(ch==1):
pname=input("Enter the new product name: ")
pri=float(input("Enter the Price: "))
prod[pname]=pri
print("\n\t Product Appended Successfully!!!")
elif(ch==2):
upn=input("Enter the product name to be updated: ")
if upn in prod:
npr=float(input("Enter the New Price: "))
prod[pname]=npr
print("\n\t Product Price Updated Successfully!!!")
else:
print("Product doesn't Exist")
elif(ch==3):
upn=input("Enter the product name to be deleted: ")
Page 41 of 56
SSM SCHOOL PROGRAM MANUAL
if upn in prod:
print(upn,end=" ")
print(prod.pop(upn),end=" ")
print("\t Product Info Deleted !!!")
else:
print("Product doesn't Exist")
elif(ch==4):
print("\nProduct Name \t Price")
for i in prod:
print(i,"\t",prod[i])
elif(ch==5):
print("Thank You:)")
else:
print("Enter the choice bw 1 and 4")
INPUT/OUTPUT:
1.Append
2.Update
3.Delete
4.Display all
5.Exit
Page 42 of 56
SSM SCHOOL PROGRAM MANUAL
Enter Ur Choice: 1
Enter Ur Choice: 2
Enter Ur Choice: 4
Colgate 20.75
Pepsodent 17.75
Sensodyne 35.0
Close Up 22.0
Enter Ur Choice: 3
Enter Ur Choice: 5
Thank You:)
RESULT:
Thus the program is executed successfully.
Page 43 of 56
SSM SCHOOL PROGRAM MANUAL
AIM:
SOURCE CODE:
book=dict()
ch=0
while ch!=6:
print("\n\n\t\t ********* Library Management System *********")
print("1. Add new \n2. Search \n3. Pop \n4. Check Total books
\n5. Clear all \n6. Exit")
ch=int(input("Enter Ur Choice: "))
if(ch==1):
bid=int(input("Enter the ISBN: "))
n=input("Enter the book name: ")
p=float(input("Enter the price: "))
y=int(input("Enter the Publication Year: "))
book[bid]=(n,p,y)
elif(ch==2):
bk=int(input("Enter the ISBN for searching: "))
if bk in book:
print(" Name, Price, Year ")
print(book.get(bk))
else:
print("ISBN not available")
elif(ch==3):
bk=int(input("Enter the ISBN for deleting: "))
if bk in book:
del book[bk]
print("Record deleted !!!!")
else:
print("ISBN not available")
Page 44 of 56
SSM SCHOOL PROGRAM MANUAL
elif(ch==4):
for i in book:
print(i,end="\t")
t=book[i]
for j in t:
print(j,end="\t")
print()
print("\n Total books : ",len(book))
elif(ch==5):
book.clear()
print("All the records deleted !!!")
elif(ch==6):
print("\n \t Thank You!!! Visit Again!!")
else:
print("Enter the valid choice between 1 and 6")
INPUT/OUTPUT:
Enter Ur Choice: 1
Enter the ISBN: 1001
Enter the book name: Operating System
Enter the price: 350
Enter the Publication Year: 2009
Enter Ur Choice: 1
Enter the ISBN: 1002
Enter the book name: Data structure
Enter the price: 420
Enter the Publication Year: 2007
Page 45 of 56
SSM SCHOOL PROGRAM MANUAL
Enter Ur Choice: 1
Enter the ISBN: 1003
Enter the book name: System Analysis and Design
Enter the price: 520
Enter the Publication Year: 2008
Enter Ur Choice: 2
Enter the ISBN for searching: 1002
Name, Price, Year
('Data structure', 420.0, 2007)
Enter Ur Choice: 4
1001 Operating System 350.0 2009
1002 Data structure 420.0 2007
1003 System Analysis and Design 520.0 2008
Total books: 3
Enter Ur Choice: 3
Enter the ISBN for deleting: 1003
Record deleted!!!
Enter Ur Choice: 5
All the records deleted!!!
Enter Ur Choice: 6
Thank You!!! Visit Again!!
RESULT:
Thus the program is executed successfully.
Page 46 of 56
SSM SCHOOL PROGRAM MANUAL
PROBLEM STATEMENT:
Write a program to create a dictionary whose keys are month names and
whose values are the number of days in the corresponding months and perform
the following functions.
1. Ask the user to enter a month name and use the dictionary to tell how
many days are in the month.
2. Print out all the months with 31 days
3. Print out all the keys in alphabetical order
4. Print out the (key-value) pair sorted by the number of days in each
month.
AIM:
To create a dictionary whose keys are month names and whose values
are the number of days in the corresponding months and perform the following
functions.
1. Ask the user to enter a month name and use the dictionary to tell how
many days are in the month.
2. Print out all the months with 31 days
3. Print out all the keys in alphabetical order
4. Print out the (key-value) pair sorted by the number of days in each
month.
SOURCE CODE:
Page 47 of 56
SSM SCHOOL PROGRAM MANUAL
INPUT/OUTPUT:
1. Enter a month to know its days
2. Months with 31 days
3. Months(Names) in alphabetical order
4. Months and days sorted by number of days in each month
5. Exit
Page 48 of 56
SSM SCHOOL PROGRAM MANUAL
Page 49 of 56
SSM SCHOOL PROGRAM MANUAL
RESULT:
Thus, the program is executed successfully.
Page 50 of 56
SSM SCHOOL PROGRAM MANUAL
PROBLEM STATEMENT:
Write a program to import math, random and statistics modules and use
the following built-in functions.
(i) math – pow, floor, gcd
(ii) random – random, randint, randrange
(iii) statistics – mean, median, mode
AIM:
To write a program to import math, random and statistics modules and
use the following built-in functions.
(i) math – pow, floor, gcd
(ii) random – random, randint, randrange
(iii) statistics – mean, median, mode
SOURCE CODE:
import math
import random
import statistics as s
while True:
print("\n1. math module \n2. random module \n3. statistics module \n4.
Exit")
ch=int(input("\nSelect a module"))
#math module
if ch==1:
#pow
print("To calculate power")
a=int(input("Enter the base:"))
b=int(input("Enter the power:"))
Page 51 of 56
SSM SCHOOL PROGRAM MANUAL
ans=math.pow(a,b)
print("The power value is =",ans)
#floor
print("To find the floor value of a number")
f=float(input("Enter a decimal number:"))
ans=math.floor(f)
print("The floor value is =",ans)
#gcd
print("To find GCD of two numbers")
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
gcd=math.gcd(a,b)
print("The gcd value is =",gcd)
#random module
if ch==2:
print("First random number :",random.random())
print("Second random number :",random.random())
print("Random integer between 1 to 12: ",random.randint(1,12))
print("Random number using randrange:",random.randrange(100,200))
#statistics module
if ch==3:
f=eval(input("Enter the list of values separated by comma:"))
m=s.mean(f)
print("The mean value is :",m)
med=s.median(f)
print("The median value is: ",med)
mod=s.mode(f)
print("The mode value is :",mod)
Page 52 of 56
SSM SCHOOL PROGRAM MANUAL
if ch==4:
print("Thank You!!!")
break
INPUT/OUTPUT:
1. math module
2. random module
3. statistics module
4. Exit
Select a module1
To calculate power
Enter the base:4
Enter the power:2
The power value is = 16.0
To find the floor value of a number
Enter a decimal number:32.8
The floor value is = 32
To find GCD of two numbers
Enter the first number:45
Enter the second number:81
The gcd value is = 9
1. math module
2. random module
3. statistics module
4. Exit
Select a module2
First random number : 0.551475377536751
Second random number : 0.9071331295429417
Random integer between 1 to 12: 2
Random number using randrange: 149
Page 53 of 56
SSM SCHOOL PROGRAM MANUAL
1. math module
2. random module
3. statistics module
4. Exit
Select a module3
Enter the list of values separated by
comma:23,48,45,21,16,38,64,21,45,78,55,45
The mean value is : 41.583333333333336
The median value is: 45.0
The mode value is : 45
1. math module
2. random module
3. statistics module
4. Exit
Select a module4
Thank You!!!
RESULT:
Thus, the program is executed successfully.
Page 54 of 56
SSM SCHOOL PROGRAM MANUAL
DATE:
AIM:
SOURCE CODE:
i=i-1
print("Binary Equivalent: ",end=" ")
while(i>=0):
print(binary[i],end="")
i=i-1
print()
o=n
octal = [0 for size in range(10)]
i=0
while(o>0):
octal[i]=int(o%8)
o=int(o/8)
i=i+1
i=i-1
print("Octal Equivalent: ",end=" ")
while(i>=0):
print(octal[i],end="")
i=i-1
print()
h=n
Page 55 of 56
SSM SCHOOL PROGRAM MANUAL
i=i-1
print("Hexadecimal Equivalent: ",end=" ")
while(i>=0):
if(hexa[i]==10):
print('A',end="")
elif(hexa[i]==11):
print('B',end="")
elif(hexa[i]==12):
print('C',end="")
elif(hexa[i]==13):
print('D',end="")
elif(hexa[i]==14):
print('E',end="")
elif(hexa[i]==15):
print('F',end="")
else:
print(hexa[i],end="")
i=i-1
INPUT/OUTPUT:
RESULT:
Page 56 of 56