Python Test 1 Objective
Python Test 1 Objective
A) hi
B) true
C) false
D) nothing
A) True
B) False
3. What gets printed? var = 100 if ( var == 100 ) : print "Value of expression is 100"
A) Nothing
B) An Error
C) Value of expression is 100
D) NONE
A) 5 10
B) 1 2 3 4 5
C) [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
D) 0, 0, 1, 1, 2, 2, 3, 3, 4, 4
A) def __init__()
B) def _init_()
C) _init_()
D) All of these
A) Howdy
B) Nothing
C) An Error
D) 10
A) 1234
B) abcd
C) u04d2
D) None of the above
A) True
B) False
9. What gets printed? def myfunc(x, y, z, a): print x + y nums = [1, 2, 3, 4] myfunc(*nums)
A) 1
B) 3
C) 4
D) 5
10. What sequence of numbers is printed? values = [1, 2, 1, 3] nums = set(values) def checkit(num): if num in
nums: return True else: return False for i in filter(checkit, values): print i
A) 1 2 3
B) 1 2 1 3
C) 1 2 13 1 2 1 3
D) Error
A) Lists
B) Dictionary
C) Tuples
D) Class
12. What gets printed? name = "snow storm" name[5] = 'X' print name
A) snow storm
B) snowXstorm
C) snow Xtorm
D) ERROR, this code will not run
A) 10
B) 2
C) 0
D) Error
15. What gets printed? def dostuff(param1, *param2): print type(param2) dostuff('apples', 'bananas',
'cherry', 'dates')
A) str
B) int
C) tuple
D) list
16. What gets printed? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print
len(mylist)
A) 1
B) 3
C) 4
D) 5
A) True
B) False
18. What is the output of the following Python program? num1 = 5 if num1 >= 91: num2 = 3 else: if num1 <
6: num2 = 4 else: num2 = 2 x = num2 * num1 + 1 print (x,x%7)
A) 21 3
B) 21 0
C) 21 21
D) NONE
19. What gets printed? if False: print('Hi') elif True: print('Hello') else: print('Howdy')
A) Nothing
B) Hi
C) Hello
D) Howdy
A) TXT
B) DAT
C) PY
D) JAVA