PROJECT
PROJECT
- Multipurpose Software
CLASS - XI
CBSE
NAME : …………….………………………………………….……………...
REG NO. : ..........................................................................
BONAFIDE CERTIFICATE
Principal Teacher – In
– charge
SCHOOL SEAL
Acknowledgement
I, ………………………………………………………………..of
Std XI , express my gratitude to our Principal,
Dr.J.Sundar for his continuous support and
encouragement.
9. To play a game
- Import the random module
- Generate a random number between 1 and 5
- Ask the user to enter their guess
- Check if the guess is equal to the number
- Print a success message
- Otherwise print a failure message and the
correct number.
if x=="1":
x=input('''what do you want to do ?
add (+)
subtract (-)
multiply (*)
divide (/)
a raised to power b (power)
square root (sqrt)
cube root (cube root)
trigonometric function (trigo)
discount (disct)
table(table)
average(avg)
:''')
import math
you=math.pi
if x=='+' :
n=int(input("how many numbers you want to
add:"))
d=0
for i in range(0,n):
b=int(input('enter no. :'))
d=d+b
print('sum is :',d)
elif x=='-':
b=int(input('enter first no. :'))
c=int(input('enter second no. :'))
d=b-c
print('difference is :',d)
elif x=='*':
n=int(input("how many numbers you want to
multiply:"))
d=1
for i in range(0,n):
b=int(input('enter no. :'))
d=d*b
print('product is :',d)
elif x=='/':
b=int(input('enter first no. :'))
c=int(input('enter second no. :'))
d=b/c
print('division is :',d)
elif x=='power':
a=int(input('enter a:'))
b=int(input('enter b :'))
d=a**b
print(a,'raised to',b,' is :',d)
elif x=='sqrt':
a=int(input('enter number:'))
b=pow(a,0.5)
print('square root of',a,'is',b)
elif x=='cube root':
a=int(input('enter number:'))
b=pow(a,1/3)
print('cube root of',a,'is',b)
elif x=='trigo':
a=input('''which operation do you want to do
sin
cos
tan
cosec
sec
cot
:''')
b=float(input('enter angle in degree:'))
c=b*(you/180)
if a=='sin':
print('Sin of',b,'is:',math.sin(c))
elif a=='cos':
print('cos of',b,'is:',math.cos(c))
elif a=='tan':
print('tan of',b,'is:',math.tan(c))
elif a=='cosec':
d=1/math.sin(c)
print('cosec of',b,'is:',d)
elif a=='sec':
d=1/math.cos(c)
print('sec of',b,'is:',d)
elif a=='cot':
d=1/math.tan(c)
print('cot of',b,'is:',d)
else :
print(a,'is not a trigonometric function')
elif x=='disct':
a=int(input('enter amount:'))
if a>0:
b=int(input('enter disount in percentage:'))
c=(a*b)/100
d=a-c
print('discount:',c,'remaining amount:',d)
else:
print('enter valid discount amount')
elif x=="table":
u=int(input("upto how many digits you want
table:"))
n=int(input("enter number:"))
for i in range(1,u+1):
print(n,"*",i,"=",n*i)
elif x=="avg":
n=int(input("how many number's average you
want?"))
A=[]
for i in range (0,n):
z=int(input("enter number:"))
A.append(z)
B=0
for i in range(0,n):
S=A[i]
B=B+S
C=B/n
print("average is:",C)
elif x=="2":
n=input("enter text")
rev(n)
elif x=="3":
n=input("input character:")
l=len(n)
if l==1:
print("ascii code of",n,"is",ord(n))
else:
print("enter one character only")
elif x=="4":
n=int(input("input ascii code:"))
if n>=0 & n<=255 :
print("ascii code=",n)
print("character=",chr(n))
else :
print("enter number in renge 0-255")
elif x=="5":
n=input("enter word containing alphabets only:")
l=n.lower()
b=n.isalpha()
if b==True:
v=0
c=0
for ch in l:
if ch=="a" or ch=="e" or ch=="i" or ch=="o" or
ch=="u" :
v=v+1
else:
c=c+1
print("no. of vowels=",v)
print("no. of consonants=",c)
else:
print("enter single word containing alphabets only")
elif x=="6":
n=input("enter text").lower()
if n==n[::-1]:
print(n,"is palindrome")
else:
print(n,"is not palindrome")
elif x=="7":
d=0
n=int(input("enter number:"))
k=n
while n>0:
s=str(n)
l=len(s)
r=n%10
c=r**l
d=d+c
n=n//10
z=d
if z==k:
print(k,"is armstrong")
else :
print(k,"is not armstrong")
elif x=="8":
A=[]
B=[]
z=int(input("enter number"))
for k in range(2,z):
if z%k==0:
n=k
a=0
for i in range (2,n):
if n%i==0:
a=a+1
if a==0:
A.append(k)
print(A)
elif x=="9":
a=random.randint(1,6)
for i in range(1,5):
n=int(input("guess no. between 1 and 5:"))
if a==n:
print("you won")
break
else:
c=4-i
if c>0:
print("try again",c,"chances left")
else:
print("you lost")
elif x=="10":
a=1
n=int(input("enter number:"))
if n==0:
print("factorial of 0 is 1")
elif n>0:
for i in range(1,n+1):
a=a*i
print("factorial of",n,"is",a)
if x=="11":
e=1
while e!=0:
print("To calculate volumes and surface areas of
following shapes ")
print("1. Cube")
print("2. Cuboid")
print("3. Cylinder")
print("4. Cone")
print("5. Sphere")
print("6. Hemisphere")
print("0. Exit")
c = int(input("Type the serial number of the shape =
"))
if c>0 and c<7:
if c == 1 :
shape = "Cube"
a=int(input("Enter the value of side of the Cube
: "))
vol=a**3
sa=6*a**2
elif c == 2:
shape="Cuboid"
l=int(input("Enter the value of length of the
Cuboid : "))
w=int(input("Enter the value of width of the
Cuboid : "))
h=int(input("Enter the value of height of the
Cuboid : "))
vol=l*w*h
sa=l*w+l*h+w*h
sa=2*sa
elif c == 3:
shape = "Cylinder"
r = int(input("Enter the value of radius of the
Cylinder : "))
h = int(input("Enter the value of height of the
Cylinder : "))
vol=22/7*r**2*h
sa=r+h
sa=2*22/7*r*sa
elif c == 4:
shape = "Cone"
r = int(input("Enter the value of radius of the
Cone : "))
h = int(input("Enter the value of height of the
Cone : "))
vol=1/3*22/7*r**2*h
s1=(r**2+h**2)**0.5
sa=r+s1
sa=22/7*r*sa
elif c == 5:
shape="Sphere"
r=int(input("Enter the value of radius of the
Sphere: "))
vol=4/3*22/7*r**3
sa=4*22/7*r**2
elif c == 6:
shape="Hemisphere"
r=int(input("Enter the value of radius of the
Hemisphere : "))
vol=2/3*22/7*r**3
sa=3*22/7*r**2
print ("Choosen shape is ",shape)
print ("Volume of ",shape,"is =",vol)
print ("Surface Area of ",shape,"is =",sa)
print ("")
str =input("Press ENTER Key to continue")
elif c>6:
print("")
print("Please enter a valid serial number of the
shape")
print("")
e=c
if e==0:
break
Output
When choice is 1
When choice is +
When choice is -
When choice is *
When choice is /
CHOICE 2
CHOICE 2
When choice is 2.
When choice is 3.
When choice is 4.
When choice is 5.
CHOICE 1
CHOICE 2
When choice is 6.
CHOICE 1
CHOICE 2
When choice is 7.
CHOICE 1
CHOICE 2
When choice is 8.
When choice is 9.
CHOICE 1
CHOICE 2
When choice is 1.
When choice is 2.
When choice is 3.
When choice is 4.
When choice is 5.
When choice is 6.
When choice is 0.
Bibliography
Introduction to Python (w3schools.com)