Loading video...

Video Failed to Load

Go Home

What is the output of following Python code?

64,935 views • 2 years ago •via X (Twitter)

10 Comments

JobFocus Services's profile picture
JobFocus Services2 years ago

Indent error

Prem Prakash's profile picture
Prem Prakash2 years ago

Wow!. As soon as if condition is met, it will break out of remaining checks & print wow!. If order is changed x = 1 if x < 2: print('Wow again!') elif x == 1: print('Wow!') else: print('No wow!'), result is Wow again!for the reason explained earlier.

CodingNerds COG's profile picture
CodingNerds COG2 years ago

The correct answer would be 'A', as the execution of the if statement would occur and then immediately exit the if loop. Consequently, the answer is 'A'.

Coffee N Code's profile picture
Coffee N Code2 years ago

Indentation is important in Python.

.m0rph 👽's profile picture
.m0rph 👽2 years ago

If the indentation was correct, then it would print WOW, but like this, it gives an error. I had my experiences with that. :-D

Robert Rees's profile picture
Robert Rees2 years ago

B If x =1 And if x is less than 2 It would be B ( wow again) I’m only new so that’s my thinking

Gauresh Alai's profile picture
Gauresh Alai2 years ago

A. Wow! As in first condition met i.e x==1. So,the program ends there and the output is (Wow!)

Rajnish🇮🇳's profile picture
Rajnish🇮🇳2 years ago

A

Tomaz Kastrun (tomaz@fosstodon.org)'s profile picture
Tomaz Kastrun ([email protected])2 years ago

IndentationError in Python world :)> Also in Python world with indentation A. Breaks w/ first TRUE.

Shibli Hasan's profile picture
Shibli Hasan2 years ago

A

Related Videos