Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

What is the output of following Python code?

64,935 Aufrufe • vor 2 Jahren •via X (Twitter)

10 Kommentare

Profilbild von JobFocus Services
JobFocus Servicesvor 2 Jahren

Indent error

Profilbild von Prem Prakash
Prem Prakashvor 2 Jahren

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.

Profilbild von CodingNerds COG
CodingNerds COGvor 2 Jahren

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'.

Profilbild von Coffee N Code
Coffee N Codevor 2 Jahren

Indentation is important in Python.

Profilbild von .m0rph 👽
.m0rph 👽vor 2 Jahren

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

Profilbild von Robert Rees
Robert Reesvor 2 Jahren

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

Profilbild von Gauresh Alai
Gauresh Alaivor 2 Jahren

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

Profilbild von Rajnish🇮🇳
Rajnish🇮🇳vor 2 Jahren

A

Profilbild von Tomaz Kastrun (tomaz@fosstodon.org)
Tomaz Kastrun ([email protected])vor 2 Jahren

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

Profilbild von Shibli Hasan
Shibli Hasanvor 2 Jahren

A

Ähnliche Videos