HNM [12] 1. Consider the function which, defined below. def which (x, y): if x >
ID: 3906590 • Letter: H
Question
HNM [12] 1. Consider the function which, defined below. def which (x, y): if x > 3 and y y or x > 7: print ('B') else: print('C') What is printed by each of these function calls? a. which (1, 9) b. which (4, 2) c. which (8, 9) d. which(1, 0) [15] 2. What is printed by the Python code? (Note: The code prints each time through the loop body!) x = 22 y = 2 while x > 5: if x > 10: x = x - y y = 2*y #6 else: x = x - 2 print (x, end='') #8 OWNA [13]3. What is printed by the Python code? Remember 'e' is not equal to 'E'. for word in ['And', 'THE', 'is', 'OH', 'a']: #1 if word. upper() == word: print (word.lower()) : 3Explanation / Answer
If you have any doubts, please give me comment...
12) 1)
a) C
b) A
c) B
d) B
15) 2) 20 18 16 14 12 10 8 6 4
13) 3)
the
oh
15) 4)
def repFile(name, s, n):
f = open(name, "w")
f.write(s*n)
f.close()
15) 5)
def teamSize(n):
if n==1:
return 'alone'
elif n==2:
return 'pair'
else
return 'group'
15) 6)
def randomPoints(n, win):
for i in range(n):
pt = Point(random.rand(0, 100), random.rand(0, 100))
pt.draw(win)
15) 7)
def allNeg(nums):
n = []
for i in nums:
if i<0:
n.append(i)
return n
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.