Question: 1. Suppose we want a program to request an integer (n) repeatedly until it is in the range 0 to 100 inclusive. Which of the

1. Suppose we want a program to request an integer (n) repeatedly until it is in the range 0 to 100 inclusive. Which of the following is the best input validation loop?

HINT: see DeMorgans law document.

A. while n < 0 or n > 100:

generate an error message

B. while n >= 0 and n <= 100

generate an error message

C. while n >= 0 or n <= 100

generate an error message

D. while n <= 0 or n >= 100

generate an error message

2. What sequence of values will be printed when the following instructions are executed?

X = 5

if (X < 7):

print(6)

Y = 6

else:

print(4)

Y = 4

if (Y < 5):

print(3)

else:

print(2)

3. What would be printed if the following instructions were executed?

X = 4

while (X > 0):

print(X)

X = X 1

4. What would be printed if the following function were executed with the value of N being 9

def xxx(N):

if (N < 7):

print(N)

else:

N = N + 3

print(N)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!