altbobz1 altbobz1
  • 24-10-2021
  • Computers and Technology
contestada

What is the value of x after running this code?

x = 0
for y in [1,2,3,4,5,6,7,8,9,10]:
x = x + y

Respuesta :

muhammadsayed06793
muhammadsayed06793 muhammadsayed06793
  • 24-10-2021

counter = 1

sum = 0

while counter <= 6:

sum = sum + counter

counter = counter + 2

print(sum)

A. 12

B. 9

C. 7

D. 8

✔️ Correct! This loop executes 3 times. After the first loop sum = 1 and counter = 3, after the second loop sum = 4 and counter = 5, and after the third loop sum = 9 and counter = 7.

Answer Link
doobthegoober doobthegoober
  • 24-10-2021
When the code runs it sums up the numbers, which results in 55. It says AFTER the code is finished so the answer will be 55. You can verify this by printing X again after the for loop
Answer Link

Otras preguntas

What is 9/10-3/5 in fractions
Benny bought 8 new baseball cards to add to his collection. The next day his dog ate half his collection. There are now only 36 cards left. How many did he star
The document that described the first government of the united states of america was called the
solve quadratic equation by completing the square x²+2x-15=0
what does asterisk mean
A change of phase never accompanies a. a change in volume b. a change in pressure c. a change in temperature d. a change in density e. a change in structure
what is 3/8 times 2/9? Answers: A 5/17 B 5/12 C 1/17 D 1/12
range of motion definition
How many levels of classification do scientists use today?
Which kind of bonds are most easily broken in water? a. ionic b. peptide c. disulphide d. single covalent e. double covalent