Write indented and documented program in Python for the following:
(a) To enter a number and check whether it is even or odd.
b) To enter three numbers and print the smallest among them.
c) To calculate simple interest,if the time is less than 5 years then the rate of interest will be 6% otherwise it will be 6.5%.
d) To display the colours of rainbow as per the user's choice.
Answers
Answer:
program 1
#input
n = int(input("Enter a Number: "))
#processing and output
if(n > 0):
print("The number is even")
elif(n == 0):
print("The number is equal to zero")
else:
print("The number is odd")
program 2
#input
a = int(input("Enter 1st number: "))
b = int(input("Enter 2nd number: "))
c = int(input("Enter 3rd number: "))
#processing and output
if(a < b and a < c):
print("1st number is smallest.")
elif(b < c):
print("2nd number is smallest.")
else:
print("3rd number is smallest.")
program 3
#input
p = float(input("Enter principle: "))
t = float(input("Enter time in years: "))
r = 6.5
#processing
if(t < 5):
r = 6.0
i = (p * r * t)/100
#output
print("Interest:", i)
I can't understand the 4th question
Answer:
oaiegrgtifochegwsoeheisowoebhdwog2u%sdskwoqpoweoru&÷=_₹^÷^÷^×[#[₹&₹;₹;&&■\£\£\■\《》●》●¥¥¤£●♤●♤|♤●££dhdjeggesiowf