Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review Fall 2004: What gets printed

Post your answers, questions, comments, comments on answers, suggestions, suggestions on questions, etc.

Back to Fall2004 Midterm 1 Review


rHelloHelloHelloHello9Hello back to you
When it says print r, it is referring it a variable, not the letter r. If it wanted to print the letter r, it would read print "r" Also, how many times will value be decremented in the loop? I think it's REMOVED than just once. Student1594


Hello back to you Hello Hello Hello Hello 9 8 7 6 Hello back to you
is this right?
Are you printing value inside the for loop? Student1594


what is the "i" in "for i in range(1,p):" ?
The i represents each number in the range as you run through the loop. So for i in range(1,3) i will be 1, the first time the loop runs, and 2 the second time it runs. Student1594

Hello back to you!
Hello
Hello
Hello
Hello
6
Hello back to you!

the last post is right but why is 6 coming out instead of 9, last time I checked:
if value = 10
value = value - 1
value = 10 - 1
value = 9
What am I missing??

^^^^^^^nevermind I got it

Can someone explain the 6? I dont get it. Thanks
The value = value - 1 is written inside the for loop so it runs as many times as the for loop runs, so on the first iteration (iteration means one step of the loop) the value decreases from 10 to 9, and then on the second iteration value starts at 9, and then is decreased by one to 8 and so on until the loop finishes. Student1594

Also, there seems to be a lack of agreement amongst the posts as th whether everything is printed on one line, or whether there are line breaks in between each print... so which is it? Student1594

things are printed as line breaks, not on one line

line breaks.

Correct Student1594

Redo the whole thing just to make clear:

Hello back to you!
Hello
Hello
Hello
Hello
6
Hello back to you!

now, is there anything wrong with it?






Link to this Page