123k views
0 votes
Bonus_val = 10

num_items = 1
if bonus_val == 10:
num_items = num_items + 3
What is the final value of num_items?

1 Answer

1 vote

Final answer:

The final value of num_items is 4 after the execution of the if-statement, as 3 is added to its initial value of 1 because bonus_val equals 10.

Step-by-step explanation:

The final value of num_items after the if-statement executes is 4. Initially, num_items is set to 1. The if-statement checks if bonus_val is equal to 10. Since bonus_val is indeed 10, the code within the if-statement is executed. Thus, 3 is added to the current value of num_items, which then becomes num_items = num_items + 3. Therefore, the final value after this operation is num_items = 1 + 3, which equals 4.

User Jonjbar
by
7.5k points