CBSE Class 11 Computer Science Question 45 of 80

Getting Started with Python — Question 10

Back to all questions
10
Question

Question 10

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 COLORS ARE BEAUTIFUL.

Answer
Step 1: INPUT number

Step 2:

IF number is between 5 and 15 THEN
    PRINT "GREEN"
ELSE IF number is between 15 and 25 THEN
    PRINT "BLUE"
ELSE IF number is between 25 and 35 THEN
    PRINT "ORANGE"
ELSE
    PRINT "ALL COLORS ARE BEAUTIFUL"