Page 4 - HA
P. 4
Home Assignment
x = x + y
y += 1
print(x, y)
test()
A. 1 3
B. 3 1
C. The program has a runtime error because x and y are not defined.
D. 1 1
E. 3 3
5. What is the output of the following code snippet?
def test(x = 1, y = 2):
x = x + y
y += 1
print(x, y)
test(2, 1)
A. 1 3
B. 2 3
C. The program has a runtime error because x and y are not defined.
D. 3 2
E. 3 3
6. What is the output of the following code snippet?
def test(x = 1, y = 2):
x = x + y
y += 1
print(x, y)
test(y = 3, x = 4)
A. 1 3
B. 2 3
C. The program has a runtime error because x and y are not defined.
D. 7 4
E. 4 7
7. What is the output of the following code snippet?
def test(x = 1, y = 2):
x = x + y
y += 1
print(x, y)
test(4)
A. 1 3
B. 6 3
C. The program has a runtime error because x and y are not defined.
D. 3 6
E. 3 3
8. Which of the following function headers is correct?
A. def f(a = 1, b):
B. def f(a = 1, b, c = 2):
C. def f(a = 1, b = 1, c = 2):
D. def f(a = 1, b = 1, c = 2, d):