Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(+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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

Find the exact value of each expression. sin(2cos -1 (-3/5)

Answered: 1 week ago