CS File 12th Class
CS File 12th Class
XII-B
Computer Science
Program File
Q-1) Write a python program to obtain 3 numbers from
the user and then display the max no and by how much
it is max from the other 2 numbers.
INPUT: -
a=float(input("Enter the first number: "))
b=float(input("Enter the second number: "))
c=float(input("Enter the third number: "))
mx=a
if b>mx:
mx=b
if c>mx:
mx=c
if mx==a:
d1=mx-b
d2=mx-c
elif mx==b:
d1=mx-a
d2=mx-c
elif mx==c:
d1=mx-a
d2=mx-b
print("Maximum number :", mx)
print("Greater than the other two numbers by :", d1,
"and", d2)
print("Made by Ishant Sharma XII-B")
Q-2) Write a python program to obtain a character
form the user and then check whether the character is
in Capital case, small case, a digit or a special character.
INPUT: -
ch = input("Enter a character: ")
if ch >= '0' and ch <= '9':
print("Digit")
elif ch.isupper ():
print("Uppercase character")
elif ch.islower ():
print("Lowercase character")
else:
print("The given character is a Special character")
print("Made by Ishant Sharma XII-B")
Q-3) Create a menu driven program to perform the
following tasks till user’s choice:-
i)Find circle’s area
ii) Find perimeter of circle
iii) Fid the surface area of cone
INPUT: -
while True:
print("Menu:")
print("1. Find circle's area")
print("2. Find perimeter of circle")
print("3. Find the surface area of cone")
print("4. Exit")
ch = input("Enter your choice: ")
if ch == '1':
radius = float(input("Enter the radius of the circle: "))
area = 3.14 * radius**2
print("Area of the circle:", area)
elif ch == '2':
radius = float(input("Enter the radius of the circle: "))
perimeter = 2 * 3.14 * radius
print("Perimeter of the circle:", perimeter)
elif ch == '3':
radius = float(input("Enter the radius of the cone: "))
length = float(input("Enter the length of the cone: "))
sa = 3.14 * radius * length
print("Surface area of the cone:", sa)
elif ch == '4':
print("Exiting program:")
break
print("Made by Ishant Sharma XII-B")