Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Put the following lines into a glowscript script and run them: energies = [ 1 0 , 1 0 , 7 , 2 ] E

Put the following lines into a glowscript script and run them:
energies =[10,10,7,2]
E =0
for energy in energies:
E = E + energy
print(E)
Notice that when you copy this code to glowscript, the indents are not copied. Since indentation is very important in python, fix the indentation in the copied code after the line that begins with for so that it looks similar to the provided code.
Match the line of programming syntax with the lettered statement describing the action of the syntax.
A Displays the sum of the energies (i.e. the total energy).
B Loops through the energies and assigns each item to energy succesively.
C Adds the value of energy to the running total.
D Assigns an initial value to the running total.
A: print(E)
B: for energy in energies:
D: E =0
C: E = E + energy
You are correct.
Your receipt no. is 158-3249 Help: Receipt Previous Tries
(b.) What is the value of the variable "energy" the second time through the for loop?
29
Feel free to add a "print(energy)" within the for loop. Look for the second value printed. For additional insight, compare what is printed to what's inside the list "energies".
Incorrect. Tries 1/99 Previous Tries
(c.) What is the final value of E

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

3 > O Actual direct-labour hours Standard direct-labour hours...

Answered: 1 week ago

Question

=+How can I use it in a new way?

Answered: 1 week ago

Question

=+2. Do they use a similar tone of voice and point of view?

Answered: 1 week ago