CBSE Class 12 Computer Science Question 18 of 57

Review of Python Basics — Question 15

Back to all questions
15
Question

Question 10

Write the output of the following program on execution if x = 50:

if x > 10:
    if x > 25:
        print("ok")
    if x > 60:
        print("good")
elif x > 40:
    print("average")
else:
    print("no output")
Answer
Output
ok
Explanation

The provided code consists of nested conditional statements to determine the output based on the value of the variable x. If x is greater than 10, it checks additional conditions. If x is greater than 25, it prints "ok," and if x is greater than 60, it prints "good." If x is not greater than 10 but is greater than 40, it prints "average." Otherwise, if none of the conditions are met, it prints "no output".

Get the Bright Tutorials app Stuck on a question? Ask Bright Buddy — your AI tutor — for step-by-step help in the app.