1.
What is the output of the following code? x = 'Hello'y = 'there'print x+y
A. 
B. 
C. 
D. 
Traceback (most recent call last):
File "", line 1, in
TypeError: unsupported operand type(s) for +: 'str' and 'str'
E. 
2.
Which of the following assignment statements are syntactically valid? w - my_name = "Brendan" x - 76trombones = "big parade"y - more$ = 10000z - my_salary = 10, 000
A. 
B. 
C. 
D. 
E. 
3.
Which of the following is not a Python basic type?
A. 
B. 
C. 
D. 
E. 
4.
What is the output of the following code?max(3, 1, abs(-11), 7, 16-10)
A. 
B. 
C. 
D. 
E. 
5.
What is the value of the parameter in the call to print_twice in the following code?def print_twice(phrase):print phrase, phrasedef print_four_times(phrase):print_twice(phrase +phrase)print_four_times('there')
A. 
B. 
C. 
D. 
'there there there there'
E. 
6.
What is the output of the following Python code?def change_param(x):x = 'Goodbye'return xx = 'Hello'print xx = change_param(x)print x
A. 
B. 
C. 
D. 
E. 
7.
Which of the following boolean expressions are True?w - 5 == 5 and 5 == 6x - 5 == 6 or 5 == 5y - 25%2 == 10%3 z - 'compl50' == 'easy'
A. 
B. 
C. 
D. 
E. 
8.
Given the following code:varl = Truevar2 = Falsevar3 = Truewhich of the following boolean expressions are False?w - varl and (var2 or var3) and (not var2)x - varl or var2y - not (varl or var2)z - varl and (var2 or var3)
A. 
B. 
C. 
D. 
E. 
9.
Given the following code:var1 = 10var2 = 5var3 = 7which of the following boolean expressions are True?w - (var1<var2) or (var2<var3)x - (var2<var3) and (var1<var2)y - (var2<var1) and (var1<var2) z - ((var1<var2) or (var2<var3)) and ((var1<20) and (var2>5))
A. 
B. 
C. 
D. 
E. 
10.
Which of the following code snippets produce the same output regardless of the value of n?xif 0<n:if n<10:print 'n is a positive single digit' yif 0<n and n<10: print 'n is a positive single digit' zif 0 < n < 10:print 'n is a positive single digit'
A. 
B. 
C. 
D. 
E. 
They all produce different Output
11.
In regards to programming style, which of the following statements are true?w - you should use 4 spaces for indentationx - imports should go at the top of the filey - variable names should be as short as possiblez - you should keep function definitions together
A. 
B. 
C. 
D. 
E. 
12.
In regards to unit testing, which of the following statements are true?w - you can't test a function if you don't know what the output should bex - unit testing guarantees the correctness of a functiony - unit testing improves the likelihood that a function is correctz - unit testing solves syntax errors
A. 
B. 
C. 
D. 
E. 
13.
Which of the following statements are true?w - to access random access memory, programs must read and write filesx - random access memory is volatiley - a hard drive is an example of non-volatile memoryz - data on non-volatile storage is stored in named locations called files
A. 
B. 
C. 
D. 
E. 
14.
Which of the following Python programs run without producing an error? wimport mathprint pi ximport mathprint math.pi yfrom math import *print math.pi zfrom math import piprint pi
A. 
B. 
C. 
D. 
E. 
15.
A namespace is:
A. 
B. 
A special Python file where all the keywords are defined.
C. 
A type, like a list, that is used to store names.
D. 
A syntactic container which permits the same name to be used in different modules or functions.
E. 
16.
What is the output of the following program?a = 5b = aa = 3print a, b
A. 
B. 
C. 
D. 
E. 
17.
What is the best explanation for the following code (assume x is an int)?x = x + 1
A. 
This code always returns False.
B. 
This code always returns True
C. 
The code has a syntax error.
D. 
The code has a semantic error.
E. 
The variable x is incremented by 1.
18.
What is the output of the following code? def countdown(n):while n>=0:print n,n = n-1print ncountdown(5)
A. 
B. 
C. 
D. 
E. 
19.
What is the output of the following code?def collatz_sequence(n):while n != 1:print n,if n%2 == 0: n = n/2else:n = n*3+1 collatz_sequence(5)
A. 
B. 
C. 
D. 
E. 
20.
What is the output of the following code?def test_while(n):i = nnum_zeros = 0while i>0:remainder = i%10if remainder ==0:num_zeros = num_zeros+1if num_zeros==3:return Truei = i/10return Falseprint test_while(123456), test_while(1002)
A. 
B. 
C. 
D. 
E. 
21.
Which of the following statements are true in the context of Graphical User Interface (GUI) programming?x - An event loop typically gets events from the user, processes events and causes windows to be redrawn.y - Callbacks are functions that are called when a GUI event occurs.z - In Tkinter, widgets must be created and placed in the root window to appear on the screen.
A. 
B. 
C. 
D. 
E. 
22.
Consider the following function definition:def read_value_type(prompt='Enter a value> ', convert=float)val= input(prompt)return convert(val) Which of the following are valid calls to read_value_type? x val = read_value_type () y val read_value_type(prompt='Enter a float> ') zval read_value_type(convert=bool, prompt='Enter a boolean> ')
A. 
B. 
C. 
D. 
E. 
23.
Consider the following code:from Tkinter import *def say_hi () :print "hi there"root = Tk ()hello button = Button(root, text="Hello", command=say_hi)hello_button.grid(row=O, column=O) root. mainloop () Which of the following statements are true? xsay_hi is the callback that gets called when the hello_button is pressed. yThe message "hi there" is output to the console when the hello...button is pressed. zA dialog box with the message "hi there" is popped up when the hello_button is pressed.
A. 
B. 
C. 
D. 
E. 
24.
What is the output of the following code?def global_variable_func():global gvargvar = "changed"1var = "changed" gvar = "not changed"1var = "not changed"global_variable_func()print "gvar has", gvarprint "1var has", 1var
A. 
Gvar has not changed
1var has not changed
B. 
Gvar has changed
1var has changed
C. 
Gvar has not changed
1var has changed
D. 
Gvar has changed
1var has not changed
E. 
25.
What is the effect of the following code?from Tkinter import *root = Tk ()gameCanvas = Canvas(root, width=200, height=200)gameCanvas.grid(row=0,column=0)x = 10y = 10dx = 1dy = 1ball gameCanvas.create_oval(x, y, x+10, y+10, fill='blue')i = 1while i<100: x += dxy += dygameCanvas.coords(ball, x, y, x+10, y+10 )i += 1 root . mainloop ()
A. 
The ball appears on the gameCanvas at the position (109, 109).
B. 
The ball initially appears on gameCanvas at the position (10, 10) and slowly moves across and down the canvas until it comes to rest at (109, 109).
C. 
The ball initially appears on gameCanvas at the position (11, 11) and slowly moves across and down the canvas until it comes to rest at (109, 109).
D. 
The ball initially appears on gameCanvas at the position (11, 11) and slowly moves across and down the canvas until it comes to rest at (110, 110).
E.