Using Python Programming Programming Essentials Write a Loop Program Write a loo
ID: 667602 • Letter: U
Question
Using Python Programming
Programming Essentials
Write a Loop Program
Write a loop that prints your name 75 times, Each instance should be followed by a newline. At the end, print the phrase “The loop is complete”
name = “Kevin”
Write a print statement to produce the following outputs given the variable below
pi = 3.14159
Pi to two decimal places is 3.14.
Pi with a leading 0 is 03.14159.
In what scenario would a while loop go on indefinitely.
There are a few ways this could happen, however the most popular answer will be if the programmer does not update the loop control variable.
Explanation / Answer
working python code
for i in range(0,75):
print "Kevin "
print "the loop is complete"
Compiled on ideone
http://ideone.com/ylsduu
working python code
pi = 3.14159
print "%0.2f" % pi
http://ideone.com/hlsm95
if condition is wrong something like
while(1)
{
}
In the above case loop will go to infinity.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.