Ask Question
7 October, 01:33

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. 7 October, 02:15
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers