Identify which of the following is NOT a Python expression. A. n + 3 B. zip \= '97403' C. 42 D. math.pi
B. zip \= '97403'
2
New cards
Identify which of the following is a valid Python floating point number. A. 'firstName' B. 3 C. 4.0 D. def
C. 4.0
3
New cards
Identify the Python integer division operator. A. div B. \# C. / D. //
C. /
4
New cards
Identify the invalid Python variable name. A. _zip4 B. zip4 C. _4zip D. 4_zip
D. 4_zip
5
New cards
The following Python code will error. Why? print("Age: " + 21) A. Print arguments must be separated by a comma B. Print arguments must be strings C. Print arguments must not be expressions D. Print is not a valid Python function
B. Print arguments must be strings
6
New cards
Identify the name given to the Python operator that combines strings. A. Combination operator B. Arithmetic operator C. Concatenation operator D. String operator
C. Concatenation operator
7
New cards
Identify the Python single line comment operator. A. \# B. ''' C. // D. def
A.
8
New cards
\#Identify the type of error encountered when a program will not execute. A. Syntax error B. Runtime error C. Semantic error D. Logic error
A. Syntax error
9
New cards
Identify the class or type displayed from the following Python code: type("University of Oregon") A. NoneType B. str C. int D. float
B. str
10
New cards
Identify the Python reserved word used to make a function a fruitful function. A. void B. reserve C. return D. function
C. return
11
New cards
Identify the availability, also known as scope of a variable defined within a function. A. Available anywhere, essentially a global variable B. Only available within the function, essentially a local variable
B. Only available within the function, essentially a local variable
12
New cards
Identify the output from the following Python function. def foo(): for i in range(4): print(i * 2, end \= '') A. 0123 B. 0246 C. 1234 D. 2468
B. 0246
13
New cards
What term is given to the act of refining your code? A. Generalization B. Encapsulation C. Refactoring D. Composition
C. Refactoring
14
New cards
Identify the shape drawn by the following Python code. t.fd(100) \# Assume t is a valid Turtle object t.lt(120) t.fd(100) t.lt(120) t.fd(100) A. Circle B. Triangle C. Square D. Line
B. Triangle
15
New cards
What contractual term is given to a function's name, argument list, behavior, and return value (if any)? A. Interface B. Generalization C. Encapsulation D. Branch
A. Interface
16
New cards
Identify the value of result in the following Python statement? result \= 5 % 2 A. 0 B. 1 C. 2 D. 5
B. 1
17
New cards
Identify the incorrect Python conditional syntax expression? A. if B. else C. else if D. elif
C. else if
18
New cards
Select the invalid Python relational operator? A. \= B. \== C. !\= D.
A. \=
19
New cards
Identify the output of the following Python code, price \= 20.0 discount \= 0.2 print(price * discount \> 18.0 or price \>\= 20) A. 18 B. 20 C. True D. False
C. True
20
New cards
Identify the final value of word_cnt in the following Python code. s \= "Peter Piper picked a peck of pickled peppers" word_cnt \= 0 for chr in s: if chr \== ' ': word_cnt \= word_cnt + 1 A. 0 B. 7 C. 8 D. 10
B. 7
21
New cards
Identify the correct syntax to escape a single quotation mark as a special character within a Python string. A. 'G'Day Mate!' B. "G'Day Mate!' C. 'G\nDay Mate!' D. 'G\'Day Mate!'
D. 'G\'Day Mate!'
22
New cards
Drawing with Python Turtle Graphics always begins in the top-left corner of the drawing window. A. True B. False
B. False
23
New cards
Identify the data type returned by Python input statements. A. float B. integer C. string D. None
C. string
24
New cards
Python fruitful functions with multiple return statements will generate a syntax error. A. True B. False
B. False
25
New cards
Identify the name given to adding and testing small amounts of code. A. Incremental development B. Refactoring C. Temporary variables D. Dead code
A. Incremental development
26
New cards
Composition is most effective when utilizing encapsulation and generalization. A. True B. False
A. True
27
New cards
Boolean functions make using the relational operator comparison unnecessary. A. True B. False
A. True
28
New cards
Identify the purpose of the isinstance() Python function. A. Exit a function B. Test the type of a variable C. Exit a loop D. Reverse a string
B. Test the type of a variable
29
New cards
Updating variables using increment and decrement do not require variable initialization. A. True B. False
B. False
30
New cards
Identify the Python statement to immediately exit a loop. A. exit B. abs C. slice D. break
D. break
31
New cards
Lengthy conditional expressions may span multiple lines using parentheses. A. True B. False
A. True
32
New cards
def repeat(data, count, spacer \= '_'): result \= '' for i in range(count): result \= result + data if i < count - 1: result \= result + spacer return result
Identify the correct output given the following function call. repeat('s', 3) A. 'sss' B. 's s s' C. 's_s_s' D. 's_s_s_'
C. 's_s_s'
33
New cards
def repeat(data, count, spacer \= '_'): result \= '' for i in range(count): result \= result + data if i < count - 1: result \= result + spacer return result
Identify the correct output given the following function call. repeat('s', 1, '-') A. 'sss' B. 's_s_s' C. 's-s-s' D. 's'
D. 's'
34
New cards
def repeat(data, count, spacer \= '_'): result \= '' for i in range(count): result \= result + data if i < count - 1: result \= result + spacer return result
Identify the reason why a for loop is appropriate for the repeat() function rather than a while loop. A. While loop does not support concatenation B. Number of iterations is unknown C. Number of iterations is known D. Break statements are not allowed in functions
C. Number of iterations is known
35
New cards
def repeat(data, count, spacer \= '_'): result \= '' for i in range(count): result \= result + data if i < count - 1: result \= result + spacer return result
The empty string assignment in the repeat() function is an example of the guardian pattern. A. True B. False
B. False
36
New cards
Common Python variable name for a file input object. A. input B. file C. fin D. t
C. fin
37
New cards
The readline() method does NOT read any line ending characters (e.g. \n). A. True B. False
B. False
38
New cards
The strip() method removes all leading, trailing and embedded white space. A. True B. False
B. False
39
New cards
Closing a file does NOT reset the file object file pointer. A. True B. False
B. False
40
New cards
The in operator can be used to search for one string within another string A. True B. False
A. True
41
New cards
Identify the syntax to declare an empty list in Python. A. my_list \= list("empty") B. my_list \= [] C. my_list \= {} D. my_list \= [:]
B. my_list \= []
42
New cards
Python lists are immutable. A. True B. False
B. False
43
New cards
Identify the value of the my_list variable after complete execution of the following code. s \= "what time is it" my_list \= s.split() A. "what time is it" B. ["what time is it"] C. ["what", "time", "is", "it"] D. ["whattimeisit"]
C. ["what", "time", "is", "it"]
44
New cards
Identify the term given when an algorithm is applied to each element in a sequence. A. Map B. Filter C. Reduction D. Delimiter
A. Map
45
New cards
Identify the correct term given to an object with more than one variable reference. A. Use case B. Equivalent C. List D. Alias
D. Alias
46
New cards
Identify the correct value of the variable piece in the following Python code. Hint: List slice works like string slice. letters \= ["A", "B", "C"] letters.append("Z") piece \= letters[1:2] A. ["A"] B. ["B"] C. ["A", "B"] D. ["B", "C"]
B. ["B"]
47
New cards
The Python is operator checks for object equivalence. A. True B. False
B. False
48
New cards
Using the in operator with a file input object and a for loop is a valid substitute for readline(). A. True B. False
A. True
49
New cards
A dictionary key may consist of mutable data types. A. True B. False
A. True
50
New cards
Dictionary searches take about the same amount of time regardless of the number of dictionary items. A. True B. False
A. True
51
New cards
Identify the statistical term for a collection of counters. A. List B. Key-value pair C. Histogram D. Lookup
C. Histogram
52
New cards
Dictionaries maintain items in sorted order. A. True B. False
B. False
53
New cards
Select the correct Boolean value of the variable result in the following code. d \= dict(A \= 'a', B \= 'b') result \= 'a' in d A. True B. False
B. False
54
New cards
Identify the syntax to declare an empty dictionary in Python. A. d \= dict("empty") B. d \= [] C. d \= {} D. d \= [:]
C. d \= {}
55
New cards
Identify the value of the variable x printed after complete execution of the following code. x \= 10 def change_global(): x \= 15 change_global() print(x)
A. 0 B. 10 C. 15 D. None
B. 10
56
New cards
Identify the correct syntax to return the second dictionary value (underlined) from the following dictionary list. t \= [{'A': 10}, {'B': 20}, {'C': 30}] A. t['B'] B. t['B'][1] C. t[1]['B'] D. t[2]['B']
C. t[1]['B']
57
New cards
A tuple is simply another term for a Python list. In other words, the terms are completely interchangeable. A. True B. False
B. False
58
New cards
Identify the correct tuple statement(s). A. tup \= 1, 2, 3 B. tup \= (1, 2, 3) C. tup \= ((1, 2, 3)) D. All the above
D. All the above
59
New cards
Identify the symbol used to indicate both gather and scatter. A. * B. % C. / D. ^
A. *
60
New cards
Identify the example of a tuple assignment. A. x, y, z \= 1, 2, 3 B. quot, rem \= divmod(16, 5) C. Neither A or B D. Both A and B
C. Neither A or B
61
New cards
Identify the correct result of the following statement. s1 \= 'abc' s2 \= 'xyz' list(zip(s1, s2))
A. [(0, 'a'), (1, 'b'), (2, 'c')] B. [('a', 'x'), ('b', 'y'), ('c', 'z')] C. 'abcxyz' D. 'axbycz'
B. [('a', 'x'), ('b', 'y'), ('c', 'z')]
62
New cards
The Python raise expression will generate a runtime exception. A. True B. False
A. True
63
New cards
Identify which of the following statements is an example of functional programming within a function. A. Modifying object variable values (e.g. lists, dictionaries) passed in as arguments B. Modifying and returning copies of object variable values
A. Modifying object variable values (e.g. lists, dictionaries) passed in as arguments