Python Programs 1-20 Class IX
Python Programs 1-20 Class IX
# Take input
a=l*b
p=2*(l+b)
total=eng+math+sc+sst+hindi
print("Dear ",name,"Your total marks out of 500 are", total, "and your percentage
is",total/500*100, "%")
area = √(s(s-a)*(s-b)*(s-c))
s = (a + b + c) / 2
temp = x
x=y
y = temp
# conversion factor
conv_fac = 0.621371
# calculate miles
miles = km * conv_fac
#Modify the above program to convert miles to kilometers. (km = miles / conv_fac)
if (num % 2) == 0:
print("Number is Even")
else:
print("Number is Odd")
10) Program to Check if a Number is Positive, Negative or 0
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
largest = num1
largest = num2
else:
largest = num3
12) Write a program to display the name of the day based on the
if day==1:
print("Its Monday")
elif day==2:
print("Its Tuesday")
elif day==3:
print("Its Wednesday")
elif day==4:
print("Its Thursday")
elif day==5:
print("Its Friday")
elif day==6:
print("Its Saturday")
elif day==7:
print("Its Sunday")
else:
i=1
print(i)
i += 1
for i in range(1,11,1):
print(i)
15) Print First 10 natural numbers in reverse order using while loop
i = 10
while i >= 1:
print(i)
i -= 1
16) Program to print the table of a given number using while loop
i=1
while i<=10:
i+=1
17) Program to print the table of a given number using for loop
18) Print First 10 natural numbers in reverse order using for loop
for i in range(10,0,-1):
print(i)
if num < 0:
else:
sum = 0
sum += num
num -= 1
num = int(input())
tot = 0
while num:
num = int(num/10)
tot = tot+1
if tot>1:
elif tot==1: