Question

Insert the missing line of code so that the following adds the integers from 1 to 10, inclusive.


image.png

16. Insert the missing line of code so that the following adds the integers from 1 to 10, inclusive. 

value = 0 

top = 10 

score = 1 

while score <= top: 

      value = value + score 

#the missing line 1


7. What is the output after the following code is executed?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

16). missing line is score=score+1

Because the code is adding numbers from 1 to 10. So we need to increase the value of score in while loop such that it will give correct values to 'value' variable. When score value is greater than 10,then while loop exits because score<=top will become false.

Answer:- score=score+1

17). The output of the following code is

1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11.

low value is increasing by 1 and simultaneously high is decreased by 1. So its printing the above output.

Add a comment
Know the answer?
Add Answer to:
Insert the missing line of code so that the following adds the integers from 1 to 10, inclusive.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT