Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
45
6
114
16.1K
Sergei Kotov
Sergei Kotov@kotov_dev·
@PythonPr Answer: B) B Simple logic: › a = 5, b = 10 › Is 5 > 10? No (False) › Condition fails → else block runs › Prints "B" For beginners: if condition is False, else block executes. Think: "if not this, then that"
English
0
0
10
1.5K
Jenny
Jenny@JennyTheDev·
@PythonPr B) B 5 > 10 is False → else branch runs The easiest Python quiz of the week
English
0
0
3
748
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Answer: B) a > b is False (5 is not greater than 10), so the else block runs and prints "B".
English
0
0
1
734
Python Tech
Python Tech@PythonTech43716·
@PythonPr B) B is the right answer. Here simple use of if and else condition. Value of a = 5 assignment opertaor Value b = 10 assignment opertaor 5>10 this condition is false then answer B is correct.
English
0
0
1
419
Unicorn Ranch .dev
Unicorn Ranch .dev@unicornRanchDev·
@PythonPr Python checks the condition first. Since 5 isn’t greater than 10, it prints B.
English
0
0
0
7
Gregor
Gregor@bygregorr·
@PythonPr Same thing happened to me when testing my app's logic: I was surprised how much time was spent debugging due to a simple assumption about variable scope. Commenting your code can be a lifesaver to avoid this kind of issue.
English
0
0
0
761
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr B. The else statement runs since a is not greater than b.
English
0
0
0
611
Khodeamiraye
Khodeamiraye@AmirayLord·
@PythonPr Question Answer is B) B Because A) = 5 > B) = 10 : NO !! B > A is true answer of question. So (False)✅
English
0
0
0
25
Evil_Hunter
Evil_Hunter@imsmartVik·
@PythonPr else block will run as condition satisfied result: B
English
0
0
0
165
Nikhil | Data Analytics
Nikhil | Data Analytics@nikku762·
@PythonPr B) Since a = 5 and b = 10, the condition a > b is false, so the else block runs and prints "B".
English
0
0
0
15
GAMBIT
GAMBIT@gambflash·
@PythonPr Exactly what I just studied yesterday night. Answer:B
English
0
0
0
91
แชร์