Ask Question
24 February, 01:54

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)

+4
Answers (1)
  1. 24 February, 05:07
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers