python while-loop

Oct 2, 2014 • Asela Wijeratne

Q1:

Which of the following is correct for a python “while-loop”?

  1. “while-loop” is preferred over “for-loops”
  2. “while-loop runs until the condition become “false”
  3. It is not necessary to test the code to see if the Boolean test becomes false at some point.
  4. “while-loop” can only iterate over collection of things

Q2:

I am watching my weight and want to reduce my weight from 170 lb to 155lb. I am trying to make a simple python code that would show me my weight loss by one pound every day and when it reaches 155, it should tell me that I have reached my goal.
Here is the code that I wrote and why is this not going to work (don’t run the code)?

weight = 170

while weight > 155:

   

   print(weight)
   weight = weight + 1

print('your weight is ideal.')