0% found this document useful (0 votes)
5 views6 pages

Question-8: Write The Python Code To See If The Obtained Number Is Positive, Negative or Zero

The document contains Python code snippets for three different tasks: checking if a number is positive, negative, or zero; calculating the areas of a circle, triangle, and rectangle based on user choice; and checking if a number is a palindrome. Each task includes input prompts and corresponding output statements. The code demonstrates basic conditional statements and loops in Python.

Uploaded by

Pulkit Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Question-8: Write The Python Code To See If The Obtained Number Is Positive, Negative or Zero

The document contains Python code snippets for three different tasks: checking if a number is positive, negative, or zero; calculating the areas of a circle, triangle, and rectangle based on user choice; and checking if a number is a palindrome. Each task includes input prompts and corresponding output statements. The code demonstrates basic conditional statements and loops in Python.

Uploaded by

Pulkit Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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")

You might also like