Flow of Control · Class 11 · CBSE · Science Computer Science

What is printed by the following Python code? x = 7 if x > 10: print("A") elif x > 5: print("B") else: print("C")

Practice question from Flow of Control (Class 11 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-5002BC

What is printed by the following Python code? x = 7 if x > 10: print("A") elif x > 5: print("B") else: print("C")

  1. A.A
  2. B.BCorrect answer
  3. C.C
  4. D.No output

Solution

The first condition is false because 7 is not greater than 10. The elif condition is true because 7 is greater than 5, so B is printed.

More from Flow of Control

All of Flow of Control

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed