Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question: 1 which values entered into ‘my_list’ would print a value of …

Question

question: 1
which values entered into ‘my_list’ would print a value of ‘-1’ after the program has run?
my_list = ...
num = 0

for thing in my_list:
num = num - thing

print(num)

5, -10, 6
-10, -5, 6
-5, 10, 6
-5, 0, 10, 6

Explanation:

Step1: Understand the program logic

The program initializes num = 0, then subtracts each element in my_list from num sequentially. We need the final num to be -1.

Step2: Test Option 1 (5, -10, 6)

Start with num=0.
0 - 5 = -5; -5 - (-10) = 5; 5 - 6 = -1. This gives -1.

Step3: Verify other options (optional)

Option2: 0 - (-10)=10;10 - (-5)=15;15-6=9≠-1.
Option3:0 - (-5)=5;5-10=-5;-5-6=-11≠-1.
Option4:0 - (-5)=5;5-0=5;5-10=-5;-5-6=-11≠-1.

Answer:

5, -10, 6