Consider the following function definitions: deffun1(n): result = 0 whilen: result += n n-- returnresult deffun2(stars): foriinrange(stars
Question:
Consider the following function definitions:
deffun1(n):
result = 0
whilen:
result += n
n--
returnresult
deffun2(stars):
foriinrange(stars + 1):
print(end="*")
print()
deffun3(x, y):
return2*x*x + 3*y
deffun4(n):
return10 <= n <= 20
deffun5(a, b, c):
returna <= bifb <= celsefalse
deffun6():
returnrandrange(0, 1)
Examine each of the following statements. If the statement is illegal, explain why it is illegal; otherwise, indicate what the statement will print. (1p each)
(a) print(fun1(5))
(b) print(fun1( ))
(c) print(fun1(5, 2))
(d) print(fun2(5))
(e) fun2(5)
(f) fun2(0)
(g) fun2(-2)
(h) print(fun3(5, 2))
(i) print(fun3(5.0, 2.0))
(j) print(fun3('A', 'B'))
(k) print(fun3(5.0))
(l) print(fun3(5.0, 0.5, 1.2))
(m) print(fun4(15))
(n) print(fun4(5))
(o) print(fun4(5000))
(p) print(fun5(2, 4, 6))
(q) print(fun5(4, 2, 6))
(r) print(fun5(2, 2, 6))
(s) print(fun5(2, 6))
(t) if fun5(2, 2, 6):
print("Yes")
else:
print("No")
(u) print(fun6( ))
(v) print(fun6(4))
(w) print(fun3(fun1(3), 3))
(x) print(fun3(3, fun1(3)))
(y) print(fun1(fun1(fun1(3))))
Taxes And Business Strategy A Planning Approach
ISBN: 9780132752671
5th Edition
Authors: Myron Scholes, Mark Wolfson, Merle Erickson, Michelle Hanlon