KnowledgeBoat Logo

Computer Applications

What is the output of following code ?

if None :
    print "Up"
else:   
    print "Down"
  1. Up
  2. Down
  3. No output
  4. Up Down

Python Control Flow

1 Like

Answer

Down

Reason — Since None is treated as false, the if condition results in false. The block of if will be ignored and the else block will be executed and Down will be printed on the output screen.

Answered By

3 Likes


Related Questions