Question-8: Write The Python Code To See If The Obtained Number Is Positive, Negative or Zero
Question-8: Write The Python Code To See If The Obtained Number Is Positive, Negative or Zero
OUTPUT:
INPUT:
n=int(input("enter a number:"))
if(n>0):
print("the number is positive")
elif(n==0):
print("the number is zero")
else:
print("the number is negative")
Question-9
Create a menu driven program to calculate the areas of three
geometrical figures, circle, triangle and a rectangle based upon
user choice.
OUTPUT:
INPUT:
print("1. enter the area of a circle")
print("2. enter the area of a square")
print("3. enter the area of a rectangle")
ch= int(input("enter choice 1/2/3"))
if ch==1:
a= int(input("enter your radius"))
print("the area of circle is:", a*a*3.14)
elif ch==2:
b= int(input("enter the base of triangle"))
c= int(input("enter the height of the triangle"))
print("the area of the rectangle", 1/2*b*c)
elif ch==3:
d= int(input("enter the length of the rectangle"))
e= int(input("enter the base of the rectangle"))
print("the area of the rectangle:",d*e)
else:
print("wrong choice")
Question-19
Obtain a number and check whether a number is a palindrome
or not.
OUTPUT:-
INPUT:-
n=int(input("enter a number"))
s=r=0
m=n
while n!=0:
r=n%10
s=s*10+r
n=n//10
if s==m:
print("yes")
else:
print("no")