0% found this document useful (0 votes)
7 views

#Multiplying Inputs

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

#Multiplying Inputs

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#Multiplying inputs

a=int(input('Enter a no. to find itsproduct with another no.'))


b=int(input('Enter a no. to find its product with another no.'))
ans=a*b
print("Answer=",ans)

#Area of circle
radius=int(input('Enter the radius of the circle in cm'))
pi=3.14
area=pi*radius*radius
print("Area=",area)

#Area and perimeter of square and rectangle


l=int(input('Enter the lenght of the rectangle to find its area and perimeter'))
b=int(input('Enter the breadth of the rectangle to find its area and perimeter'))
area=l*b
print("Area=",area)
perimeter=2*l+2*b
print("Perimeter=",perimeter)
#Area of Square
side=int(input('Enter the lenght of one side of the square to find its area and
perimeter'))
area=side*side
print("Area=",area)
perimeter=4*side
print("Perimeter=",perimeter)

#Cube and square of a no.


n=int(input('Enter a no. to find its square and cube'))
square=n*n
cube=n*n*n
print("Cube of",n,"=",cube)
print("Square of",n,"=",square)

#Is the entered alpahbet a vowel or consonant


b=str(input('Enter an alphabet to check whether its a vowel or consonant'))
a = b.lower()
if(a=='a' or a=='e' or a=='i' or a=='o' or a=='u'):
print(b, "is a vowel")
elif(a=='b' or a=='c' or a=='d' or a=='f' or a=='g' or a=='h' or a=='j' or a=='k'
or a=='l' or a=='m' or a=='n' or a=='p' or a=='q' or a=='r' or a=='s' or a=='t' or
a=='v' or a=='w' or a=='x' or a=='y' or a=='z'):
print(b, "is a consonant")
else:
print("Please enter a valid alphabet from a-z")

#Check whether entered no. is odd or even


n=int(input('Enter a no. to check if it is odd or even'))
if(n%2==0):
print(n,"is a even no.")
else:
print(n,"is a odd no.")
#leap year or not
yr=int(input('Enter a year to check if it is a leap year or not'))
if(yr%4==0 and yr%100!=0 or yr%400==0):
print (yr," is a leap year")
else:
print(yr,"isn't a leap year")
#negative or positive
n=int(input('Enter a no. to check whether it is negative or positive'))
if(n>0):
print(n,"is a positive no.")
elif(n<0):
print(n,"is a negative no.")
else:
print(" 0 is neither positive nor negative.")

#colors of the rainbow


c=str(input('Enter the first letter from the rainbow color you want to display
ex:VIBGYOR')).lower()
if (c=='v'):
print("The color is violet")
elif(c=='i'):
print("The color is Indigo")
elif(c=='b'):
print("The color is Blue")
elif(c=='g'):
print("The color is Green")
elif(c=='y'):
print("The color is Yellow")
elif(c=='o'):
print("The color is Orange")
elif(c=='r'):
print("The color is Red")
else:
print("Please choose from VIBGYOR")

#For loop
for a in range(15,85):
if (a%2==0):
print(a," is even no")

#count the no. of vowels in a given string


a=str(input('Enter a string to check how many vowels does it have')).lower()
c=a.count('a')
b=a.count('e')
d=a.count('i')
e=a.count('o')
f=a.count('u')
n=b+c+d+e+f
print("No. of vowels in", a,"=",n)

#Factors of a given no.


n=int(input('Enter a no. to find its factors'))
for i in range (1,n+1):
if (n%i==0):
print(i,"is a factor of ",n)

#Prime or composite no.


n=int(input('Enter a no. to check if it is prime or composite'))
if n>1:
for i in range(2,n):
if (n%i==0):
print(n,"is a composite no.")
break
else:
print(n,"is a prime no.")
elif n== 0 or 1:
print(n,"is neither prime nor composite")
else:
print("Please enter a valid input")

You might also like