Q. Write an algorithm that performs the following:

Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is between 15 and 25, write the word BLUE. if the number is between 25 and 35, write the word ORANGE. If it is any other number, write that ALL COLOURS ARE BEAUTIFUL.

Answer :-

Input number

If 5 < number <= 15 then
    Print GREEN

elif 15 <  number <= 25then
     Print BLUE

elif 25 < number <= 35 then
     Print ORANGE

else :
      Print ALL COLOURS ARE BEAUTIFUL.

Python code :-

number = int(input("Enter a Number :- "))

if (5 < number) and (number <= 15 ):
    print(" GREEN")

elif (15 <  number) and (number <= 25):
    print(" BLUE")

elif (25 < number) and(number <= 35 ):
    print ("ORANGE")
    
else :
    print(" ALL COLOURS ARE BEAUTIFUL.")

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post