Trial midterm exam with solutions - 2023
Introduction to python (Universiteit van Amsterdam)
, lOMoARcPSD|70337540
Test Trial midterm - Introduction to Python - 22/23
Question 1 − Basics−Logic−3 − 355237.1.2
What is the output of the following code snippet?
x=1
y = 15
print(not(not(x < 3) and not(y > 14 or y > 10)))
A The code will result in a SyntaxError.
B True
C False
D 0
Question 2 − Basics−Loop−2 − 354680.1.0
What is the output of the following code snippet?
list1 = [1, 2, 3, 4, 5]
list2 = [2, 4, 6, 8, 10]
list3 = []
for i in list1:
for j in list2:
if i + j >= 10:
break
list3.append(i + j)
print(list3)
A [3, 5, 7, 9, 4, 6, 8, 5, 7, 9, 6, 8, 7, 9]
B [3, 5, 7, 8, 9, 6, 8, 10]
C [3, 5, 7, 8, 9, 6, 8, 9]
D This code will result in an IndexError.
Page 1/12 - Trial midterm - Introduction to Python - 22/23 - 198513.1.3