Computer Science

What is the output produced by the following code?

x = 1                        
if x > 3 :
   if x > 4 :                
         print ("A", end = ' ')
   else :                    
         print ("B", end = ' ')
elif x < 2:                  
   if (x != 0):
         print ("C", end = ' ')
print ("D")                  

Python

Python Control Flow

66 Likes

Answer

C D

Working

As value of x is 1 so statements in the else part of outer if i.e. elif x < 2: will get executed. The condition if (x != 0) is true so C is printed. After that the statement print ("D") prints D.

Answered By

23 Likes


Related Questions