Post

@PythonPr This is a classic "gotcha" question! If you're looking at the logic the creator intended, the answer is C (120). However, if you're looking at how Python would actually behave, the code is full of traps.
Here is the breakdown of why this code is trickier than it looks:
English

@PythonPr Answer: C) 120
Step by step:
› Filter: x > 20 (30, 40, 50)
› sum(30, 40,50) = 120
For beginners: "if x > 20" filters the list first, then sum() adds them up.
English

@PythonPr C) 120
Only values > 20 are summed → 30 + 40 + 50 = 120.
English

@PythonPr None of the selections because X is capital letter in line 2, and X is not declared.
English

@PythonPr Actually, the code cannot run "print(resutt)" kkkk. Adding "resutt=result" before print, the code will add all the numbers of the list "if" the number is bigger than 20. The result is 120 ( 30+40+50).
English

@PythonPr C - 10 and 20 are dropped as they are not bigger than 20
English

@PythonPr raised exception because X (capital) is not defined
English





















