Ask Question

Consider the following code:

a) num = int (input ("Enter a number, negative to stop"))

b) while (num > = 0):

print ("You entered: " + str (num))

c) num = int (input ("Enter a number, negative to stop"))

print ("Done.")

What is wrong?

d) The num > = 0 test condition is not correct

There is nothing wrong with the code.

The line num = int (input ("Enter a number, negative to stop")) should be indented so it is inside the loop

e) There should not be a : after the while (num > = 0)

+3
Answers (1)
  1. 9 April, 13:46
    0
    The num > = 0 test condition is not correct

    Explanation:

    The line would lead to the printing of "Your entered: " + str (num) repeatedly without stopping.

    The while loop checks the condition that the "num" variable is less than zero. This condition will always be true as there is no means of resetting the value after initially inputting the value that is less than zero.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the following code: a) num = int (input ("Enter a number, negative to stop")) b) while (num > = 0): print ("You entered: " + str ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers