Question
(+5 ) What number would be printed if the following function were executed? def f(x,y): t = x * y s = t // 3
(+5 ) What number would be printed if the following function were executed?
def f(x,y): t = x * y s = t // 3 s = s % 5 return s a = 21 b = 4 n = f(a,b) # call f with a b as parameters print(n)
a. 0 b. 1 c. 2 d. 3 e. 4
(+5) What sequence of numbers would be printed if the following function were executed ?
def xxx(N): while (N < 4): print(N) N = N + 2 print(N) b = 1 n = xxx(b) # call xxx with b as parameter print(n)
a. 1, 3, 3, 3, 5 b. 1, 3, 3, 5, 5
c. 1, 3, 5 d. 1, 3, 3, 5
3.(+5) Suppose we want a program to request an integer (n) repeatedly until it is in the range 0 to 100 inclusive ( n >= 0 and n <= 100) Which of the following can be used as the best input validation loop? HINT: see DeMorgans law document.
while n < 0 and n > 100:
generate an error message
while n >= 0 and n <= 100
generate an error message
while n >= 0 or n <= 100
generate an error message
while n < 0 or n > 100
generate an error message
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started