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

you can drive 360 miles on 12 gallons in 4 hours. how far can you drive on one gallon?​(I put the wrong subject
I need urgent help with these types of problems bc I suck at geometry please ITS URGENT SOMEONE HELP I BEg of you!
calculate the mass of air in a room 5m × 4m ×2m given that the density of air is 1.3kgm-²​
What are valence elections?
prove that 2√3÷5 is irrational​
Which statements apply to theories? Check all that apply. A theory is a factual statement. B theory is well-tested and widely accepted. C theory is an explanati
What did peasants gain after the French Revolution
graph the surface of equation z=1/5y^2-3|x|
Special Right Triangles: Decimal Answer ! What’s H and C ?! Help me please?! Round to the nearest tenth.
7. What is the value of c so that -9 and 9 are both: olz Hallo