Python Exam Func
Python Exam Func
2. What do you call a computer program which directly executes instruction written
in a programming language?
A. A compiler
B. A translator
C. An interpreter
print(“Goodbye!”)
A. 17
B. The snippet will cause an execution error
C. 17.0
D. 25.
10. What is the Output of the following snippet if the user enters two lines containing
“11” and “4” respectively?
x = int(input())
y = int(input())
x=x%y
x=x%y
y=y%x
print(y)
A. 2
B. 3
C. 1
D. 4
11. The meaning of the keyword parameter is determined by:
A. The argument’s name specified along with its value.
B. Its connection with existing variables
C. Its position within the argument list
D. Its value
12. What is the output of the following snippet if the user enters two line containing “2”
and “4” respectively?
x = int(input())
y = int(input())
x=x/y
y=y/x
print(y)
13. What it the output of the following snippet if the user enters two lines containing
“3” and “6” respectively?
x = input()
y = int(input())
print (x * y)
A. 666
B. 18
C. 333333
D. 36
A. 111
B. 1*1*1
C. x*y*z
D. xyz
16. Left-sided binding determines that the result of the following expression:
1 // 2 * 3
Is equal to:
A. 4.5
B. 0.0
C. 0
D. 0.16666666666666666666
17. Which of the following statements are true? (Select two answers)
A. The ** operator uses right-sided blinding.
B. Addition precedes multiplication.
C. The right arguments of the % operator cannot be zero.
D. The result of the / operator is always an integer value.
18. What is the output of the following snippet if the user enters two lines containing 2
and 4 respectively?
x = input()
y = input()
print (x + y)
A. 4
B. 24
C. 6
D. 2
19. What is the output of the following snippet?
x=1
y=2
z=x
x=y
y=z
print(x, y)
A. 21
B. 22
C. 11
D. 12
20. Which of the following variable name are illegal? (Select two answers)
A. TRUE
B. true
C. True
D. and
22. What is the output of the following snippet if the user enters two line containing 2
and 4 respectively?
x = int(input())
y = int(input())
x=x//y
y=y//x
print(y)
A. 8
B. 17.5
C. 17
D. 8.5
26. The most important difference between integer and floating-point number lies in
the fact that:
A. Integers cannot be literals, while floats can
B. They cannot be used simultaneously
C. They are stores differently in the computer memory
31. An operator able to check whether two values are not qual is coded as:
A. !=
B. not ==
C. <>
32. How many star will the following snippet send to the console?
i=2
while i >= 0:
print(“*”)
i-=2
A. Three
B. One
C. Two
33. How many hashes will the following snippet send to the console?
for i in range(-1, 1):
print(“#”)
A. Three
B. Two
C. One
34. What value will be assigned to the x variable?
z = 10
y=0
x = z > y or z == y
A. False
B. True
C. 1
A. [3, 1, 1]
B. [3, -1, 1]
C. [1, 1, -1]
36. Take a look at the snippet and choose one of the following statements which is true:
nums = []
vals = nums
vals.append(1)
37. Take a look at the snippet and choose one of the following statement which is true:
nums = [ ]
vals = nums[ : ]
vals.append(1)
A. Three
B. Two
C. One
A. 0
B. 6
C. 1
A. 3
B. 1
C. -2
44. Which of the following statements are true? (select two answers)
A. The return keyword forces the function’s execution to terminate
B. The return keyword forces the function to restart its execution
C. The return keyword may cause the function to return a value
47. If a list is passed into a function as an argument, deleting any of its elements inside
the function using the “ del “ instruction:
A. Will affect the argument
B. Will not affect the argument
C. Will cause a runtime error
A. 9
B. 6
C. The snippet is erroneous (invalid syntax)
49. What is the output of the following snippet?
tup = (1, ) + (1, )
tup = tup + tup
print(len(tup))
A. 2
B. 4
C. The snippet is erroneous (invalid syntax)
50. Which of the following lines properly starts a function using two parameters, both
with zeroed default values?
any()
print(var)
A. 22
B. 11
C. 21
D. 12
52. What is the output of the following snippet?
my_list = ['Mary', 'had', 'a', 'little', 'lamb']
def my_list(my_list):
del my_list[3]
my_list[3] = "ram"
print(my_list(my_list))
print(fun(out=2))
A. 4
B. The snippet is erroneous
C. 2
D. 6
print(fun(fun(2)) + 1)
A. 1
B. The code will cause a runtime error
C. None
D. 2
55. A built-in function is a function which:
A. Has been placed within your code by another programmer
B. Has to be imported before use
C. Is hidden from programmers
D. Comes with Python, and is an integral part of Python
print(func(2))
A. will output – 4
B. is erroneous
C. will output – 2
D. will return – None
for k in range(len(dic)):
v = dic[v]
print(v)
A. three
B. two
C. (‘one’, ‘two’, ‘three’)
D. one
58. The following snippet:
def f1(a):
return a ** a
def f2(a):
return f2(a) * f2(a)
print(f2(2))
A. is erroneous
B. will output = 2
C. will output = 16
D. will output = 4
A. 3
B. 0
C. The snippet is erroneous
D. 9
x=2
x = fun(x + 1)
print(x)
A. 4
B. The code is erroneous
C. 5
D. 3
61. What is the output of the following snippet?
def fun(x):
global y
y=x*x
return y
fun(2)
print(y)
A. None
B. The code will cause a runtime error
C. 4
D. 2
62. What code would you insert instead of the comment to obtain the expected output?
Expected Output:
a
b
c
code:
dictionary = {}
my_list = [‘a’, ‘b’, ‘c’, ‘d’]
for i in sorted(dictionary.keys()):
k = dictionary[i]
# Insert your code here.
A. print(k)
B. print(k[0])
C. print(k[‘0’])
D. print(k[“0”])
63. What is the output of the following snippet?
tup = (1, 2, 4, 8)
tup = tup[1:-1]
tup = tup[0]
print(tup)
A. (2)
B. 2
C. (2, )
D. The snippet is erroneous
print(f(3))
A. 3
B. 1
C. The code is erroneous
D. 6
65. Which one of the following lines properly starts a parameter less function
definition?
A. function fun():
B. fun function():
C. def fun():
D. def fun:
A. 11
B. 01
C. 10
D. 00
A. zero
B. one
C. two
D. three
70. The following snippet:
def function_1(a):
return None
def function_2(a):
return function_1(a) * function_1(a)
print(function_2(2))
A. 44
B. (4)
C. 4
D. (4, )
72. Assuming that “ my_tuple” is a correctly created tuple, the fact that tuples are
immutable means that the following instruction:
my_tuple[1] = my_tuple[1] + my_tuple[0]
for k in range(len(dct)):
v = dct[v]
print(v)
A. three
B. (‘one’, ‘two’, ‘three’)
C. two
D. one
A. True
B. False
C. 1
D. 0
75. What is the output of the following piece of code if the user enters two lines
containing “ 2 “ and “ 4 “ respectively?
x = float (input())
y = float (input())
print(y ** (1/x))
A. 0.0
B. 2.0
C. 1.0
D. 4.0
76. What is the output of the following snippet?
def fun(x):
if x % 2 == 0:
return 1
else:
return 2
print(fun(fun(2)))
A. 2
B. The code will cause a runtime error
C. 2None
D. 1
A. abc
B. asepbsepc
C. asepbsepcsep
D. abc
print(fun(out=2))
A. 2
B. 6
C. The snipper is erroneous and will cause SyntaxError
D. 4
80. What is the output of the following piece of code?
x=1
y=2
x, y, z = x, x, y
z, y, z = x, y, z
print(x, y, z)
A. 212
B. 122
C. 112
D. 121
81. How many stars(*) will the following snippet send to the console?
i=0
while i < i + 2:
i+=1
print(“*”)
else:
print(“*”)
A. One
B. Zero
C. The snippet will enter an infinite loop. Printing one star per line
D. Two
82. Take a look at the snippet and choose the true statements:
nums = [1, 2, 3]
vals = nums
del vals[:]
print(fun(0, 3))
84. Which of the following variable names are illegal and will cause Syntax Error
exception? (Select two answers)
A. print
B. In
C. for
D. in
85. What is the output of the following piece of code if the user enters two lines
containing “ 3 “ and “ 6 “ respectively?
y = input()
x = input()
print(x + y)
A. 3
B. 63
C. 6
D. 36
86. What is the output of the following snippet?
my_list = [1, 2]
for v in range (2):
my_list.insert(-1, my_list[v])
print(my_list)
A. [2, 1, 1, 2]
B. [1, 1, 1, 2]
C. [1, 2, 2, 2]
D. [1, 2, 1, 2]
87. What is the output of the following piece of code if the user enters two lines
containing “ 3 “ and “ 2 “ respectively?
x = int(input())
y = int(input())
x=x%y
x=x%y
y= y % x
print(y)
A. 3
B. 2
C. 0
D. 1
def fun(lst):
del lst[lst[2]]
return lst
print(fun(my_list))
A. [0, 1, 4, 9]
B. [1, 4, 9, 16]
C. [0, 1, 9,16]
D. [0, 1, 4,16]
for x in dct.keys():
print(dct[x][1], end=””)
A. 12
B. 21
C. (1,2)
D. (2,1)
91. How many hashes (#) will the following snippet send to the console?
lst = [[x for x in range(3)] for y in range(3)]
A. six
B. nine
C. zero
D. three
A. 0.4
B. 0
C. 0.2
D. 0.0
A. 1
B. 3
C. 2
D. 4
94. Which punctuation symbol should be used to combine string and number in a print
statement?
A. ,
B. &
C. +
D. @
96. Which built-in function should be wrapped around the variable, widget, to cast it
into a string variable?
A. str
B. string
C. stringtype
D. cast/str
101. Which number will be shown when the sales variable is run in a print statement?
A. 31000
B. 53235
C. 30000
D. 32000
102. Which type of variables uses decimals?
A. Integer
B. Boolean
C. Floating
D. String
A. Integer
B. String
C. Boolean
D. Floating
104. Based on the assignments displayed on line 2, the print statement on line six is False:
A. True
B. False
108. Which entry should be in the blue highlighted area in order to implements properly
the pass keyword?
A. pass
B. pass statement
C. begin pass
D. pass keyword
109. Which entry should be in the blue highlight area in order to set up correctly a break
statement?
A. break End
B. break loop
C. break while loop
D. break
110. Which entry should be in the blue highlighted area in order to set up correctly the
for loop to cover every month of the year?
A. 1,13
B. 1,12
C. 0,12
D. 12
111. Select the correct from of the if statement from multiple answer in the code sample
in order to return the print statements shown for customers who have annual sales
of at least 500,000.
A. if>=500000:
B. if annualSales >= 500000:
C. if annualSales = 500000:
D. if = 500000: