Robotics & Artificial Intelligence

Check that the following code snippet will execute properly or not. Justify your answer.

a=10 
b=25 
if a<b: 
print("a is less than b") 
else: 
print("b is less than a")

Python Control Flow

3 Likes

Answer

Output: No output

Justification: The given code snippet will not execute properly because of incorrect indentation. In Python, it is mandatory to indent the statements inside the if and else blocks. If the statements under the if condition are not indented, Python will display an IndentationError and the program will not run. Since the print() statements are not indented under if and else, the code is syntactically incorrect.

Answered By

1 Like


Related Questions