Computer Science

What is the output of the following lines of code?

if int('zero') == 0 :       
   print ("zero")            
elif str(0) == 'zero' :          
   print (0)                  
elif str(0) == '0' :         
   print (str(0))             
else:                         
   print ("none of the above")

Python

Python Control Flow

55 Likes

Answer

The above lines of code will cause an error as in the line if int('zero') == 0 :, 'zero' is given to int() function but string 'zero' doesn't have a valid numeric representation.

Answered By

33 Likes


Related Questions