CLASS 9 PROGRAM LIST
1. #program to calculate the area of a triangle.
h = float(input("Enter the height of your triangle: "))
b = float(input("Enter the base of your triangle: "))
area = 0.5*h*b
print("The area of your triangle is: ", area)
2. #program to calculate the exponential value of a number.
a = int(input("Enter your base number: "))
b = int(input("Emter the exponent of your number: "))
exp = a ** b
print("The exponential value of your number is : ", exp)
3. #program to calculate surface area and volume a cuboid.
length = float(input("Enter the length of your cuboid: "))
width = float(input("Enter the width of your cuboid: "))
height = float(input("Enter the height of you cuboid: "))
surface_area = 2*(length*width + length*height + width*height)
volume = length*width*height
print("Surface area: ", surface_area)
print("Volume: ", volume)
print("Note: All measurements are displayed in cm.")
4. #program to decide if a student has passed or failed, based on their marks.
marks = int (input("Enter your number: "))
if (marks>35):
print("The candidate has passed.")
else:
print("The candidate has failed.")
5. #program to decide whether a number is even or odd.
num = int(input("Enter your number: "))
if ((num % 2)== 0):
print("It is an even number.")
else:
print("It is an odd number.")
6. #program to decide between profit or loss.
cp = int(input("Enter the cost price: "))
sp = int(input("Enter the selling price: "))
profit = sp-cp
loss = cp-sp
if cp<sp:
print("The profit is: ", profit)
elif cp>sp:
print("The loss is: ", loss)
else:
print("No profit, No loss.")
7. #program to decide, out of 2 numbers, which is greater.
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
if num1>num2:
print("The first number is greater.")
elif num1<num2:
print("The second number is greater.")
else:
print("Both the numbers are equal.")
8. #program to print numbers from 1 to 10 using range(n) function.
for i in range(1, 11):
print(i,end=" ")
9. #program to print a multiplication table of a number.
n = int(input("Enter your number: "))
for i in range (1,11):
print(n,"x",i,"=", n*i)
10. # Calculating sum of elements of a list
numbers=[6, 5, 3, 8, 4, 2, 5, 4, 11]
sum=0
for i in numbers:
sum=sum + i
print("sum is:", sum)