Class x Python Prg s
Class x Python Prg s
Advanced Python
Prg1. Write a program to calculate Volume and Surface Area of a Cuboid.
Hint:
Volume of cuboid=l*w*h
SurfcAr of cuboid= 2*(l*w +l *h+ w*h)
VC= L*W*H
print(“Volume of Given Cuboid = ”, VC)
SA=2*(L*W + L*H + W*H)
print(“Surface Area of Given Cuboid =” , SA)
Prg 2. Write a program to ask for height in centimetres and convert it into feet and inches.
Hcms= float(input(“Enter your height in centimetres :\t ”))
Hinch = Hcms/2.54
Hfeet = Hinch // 12
Inch = Hinch % 12
Prg3. Write a Python program to calculate the area of triangle using Heron’s formula.
Hint: s=(a+b+c)/2. Ar=sqrt of (s-(s-a)*(s-b)*(s-c))
s=(a+b+c)/2.
area=((s-(s-a)*(s-b)*(s-c))**0.5)
print(“Area of Triangle = ”, area)
Prg 4. Write a Python program to input cost amount and selling amount and display profit or loss.
Prg 5. Write a program that accepts three colours from the user. If the user enters orange, red and green, respectively, the message "Indian Flag" is displayed,
otherwise, the message "Not an Indian Flag" is displayed.
color1 = input("Enter the first color: ").strip().lower()
color2 = input("Enter the second color: ").strip().lower()
color3 = input("Enter the third color: ").strip().lower()
if color1 == “orange” and color2 == "white" and color3 == "green":
print("This is Indian Flag")
else:
print("This is not Indian Flag")
Prg 6. Write a program to enter the age and height of a person and display the message if he is eligible to write the roller coaster or not. [Crietaria: The age must
be above 18 and the height must be above 1.5 meters]
Prg 7. Write a program to find the sum, product and average of 10 numbers entered by the user.
Sum=0
Product= 1
print(“Enter the numbers…”)
for i in range(1,11):
n = int(input(“ Number ” + str(i) + “\t”))
Sum = Sum + n
Product = Product * n
print(“Sum of numbers entered = ”, Sum)
print(“Product of numbers entered = ”, Product)
Avrg = Sum / 10
print(“Average of numbers = ”, Avrg)
Prg 8. Write a program to check whether the number input by the user is an Armstrong number or not.
[Armstrong Number: Sum of cubes of each digit = Number]
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum = sum + digit ** 3
temp = temp - temp // 10
if num == sum:
print(num, "is an Armstrong number")
else:
print(num, "is not an Armstrong number")
Prg 9. Write a program to accept a number and print sum of following series:
1/1! + 2/2! + 3/3! + n/n!
n = int(input("Enter a number : "))
seriesSum = 0
factorial = 1
for i in range(1, n + 1):
factorial = factorial * i
term = i / factorial
seriesSum = seriesSum + term
print(“The sum of Series is : ”, seriesSum)
Prg 10. Write a program to store rollnumber wise names of your classmates in a list. Display the student name as per the roll number entered.
ClassStudents = [ ]
N = int(input(“Enter strength of class. ”))
for i in range(N) :
Sname=input(“Enter student name for Roll Number : \t ”+str(i+1))
ClassStudents.append(Sname)
print(“Enter Roll Number to See Student Name : ”)
rno = int(input())
if rno > N or rno<=0 :
print(“Sorry, this roll number is not there!”)
else :
print(Class students[rno - 1])