Question: Write an expression that executes the loop body as long as the user enters a non-negative number. Note: These activities may test code with different

Write an expression that executes the loop body as long as the user enters a non-negative number.
Note: These activities may test code with different test values. This activity will perform three tests, with user_num initially 9 and user input of 5, 2, -1, then with user_num initially 0 and user input of -17, then with user_num initially -1. See How to Use zyBooks.
Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.

1

2

3

4

5

6

user_num = 9;

while (user_num <= 9):

print('Body')

user_num = int(input())

print('Done.')

***Must be in pyhton****

Step by Step Solution

3.39 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To achieve the desired behavior where the loop continues as long as the user inputs a nonnegative nu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

60961c9e672a9_26616.pdf

180 KBs PDF File

Word file Icon

60961c9e672a9_26616.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!