Question: hours = int(input('Enter number of hours worked: ')) # insert input validation loop here gross_pay = hours * 10 print('Gross pay:', gross_pay) Suppose we want

hours = int(input('Enter number of hours worked: '))

# insert input validation loop here

gross_pay = hours * 10

print('Gross pay:', gross_pay)

Suppose we want the program to ask for number of hours worked repeatedly until it is within the range of 0 to 168.

Which of the following is the best input validation loop?

A.

while hours < 0 or hours > 168:

print('ERROR: Number of hours worked must be between 0 and 168')

hours = int(input('Enter number of hours worked last week: '))

B.

while hours >= 0 and hours <= 168:

print('ERROR: Number of hours worked must be between 0 and 168')

hours = int(input('Enter number of hours worked last week: '))

C.

while hours >= 0 or hours <= 168:

print('ERROR: Number of hours worked must be between 0 and 168')

hours = int(input('Enter number of hours worked last week: '))

D.

while hours < 0 or hours > 168:

print('ERROR: Number of hours worked must be between 0 and 168')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To ensure the input for the number of hours worked is validated within the correct range which is fr... 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

Students Have Also Explored These Related Databases Questions!