正在加载视频...

视频加载失败

What is the output of following Python code?

64,935 次观看 • 2 年前 •via X (Twitter)

10 条评论

JobFocus Services 的头像
JobFocus Services2 年前

Indent error

Prem Prakash 的头像
Prem Prakash2 年前

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 的头像
CodingNerds COG2 年前

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 的头像
Coffee N Code2 年前

Indentation is important in Python.

.m0rph 👽 的头像
.m0rph 👽2 年前

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 的头像
Robert Rees2 年前

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 的头像
Gauresh Alai2 年前

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

Rajnish🇮🇳 的头像
Rajnish🇮🇳2 年前

A

Tomaz Kastrun (tomaz@fosstodon.org) 的头像
Tomaz Kastrun ([email protected])2 年前

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

Shibli Hasan 的头像
Shibli Hasan2 年前

A

相关视频