Reference no: EM131489115
Question: 1. If you were to look at a machine language program, you would see __________.
a) Python code
b) a stream of binary numbers
c) English words
d) circuits
2. A(n) ____________ is a set of instructions that a computer follows to perform a task.
a) compiler
b) program
c) interpreter
d) programming language
3. The words that make up a high-level programming language are called __________.
a) binary instructions
b) mnemonics
c) commands
d) key words
4. The rules that must be followed when writing a program are called __________.
a) syntax
b) punctuation
c) key words
d) operators
5. A syntax error does not prevent a program from being compiled and executed.
a) True
b) False
6. A __________ error does not prevent the program from running, but causes it to produce incorrect results.
a) syntax
b) hardware
c) logic
d) fatal
7. A(n) __________ is a set of well-defined logical steps that must be taken to perform a task.
a) logarithm
b) plan of action
c) logic schedule
d) algorithm
8. An informal language that has no syntax rules and is not meant to be compiled or executed is called __________.
a) faux code
b) pseudocode
c) Python
d) a flowchart
9. A string literal in Python must be enclosed in __________.
a) parentheses
b) single-quotes
c) double-quotes
d) either single-quotes or double-quotes
10. Short notes placed in different parts of a program explaining how those parts of the program work are called __________.
a) comments
b) reference manuals
c) tutorials
d) external documentation
11. Which of the following statements will cause an error?
a) x = 17
b) 17 = x
c) x = 99999
d) x = '17'
12. Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of this data type.
a) int
b) float
c) currency
b) str
13. This built-in function can be used to convert an int value to a float.
a) int_to_float()
b) float()
c) convert()
d) int()
14. In a math expression, multiplication and division takes place before addition and subtraction.
a) True
b) False
15. Variable names can have spaces in them.
a) True
b) False
16. If you print a variable that has not been assigned a value, the number 0 will be displayed.
a) True
b) False
17. A __________ structure can execute a set of statements only under certain circumstances.
a) sequence
b) circumstantial
c) decision
d) Boolean
18. A(n) __________ expression has a value of either true or false.
a) binary
b) decision
c) unconditional
d) Boolean
19. The symbols >, <, and == are all __________ operators.
a) relational
b) logical
c) conditional
d) ternary
20. A compound Boolean expression created with the __________ operator is true only if both its subexpressions are true.
a) and
b) or
c) not
d) both
21. A compound Boolean expression created with the __________ operator is true if either of its subexpressions is true.
a) and
b) or
c) not
d) either
22. A __________ is a Boolean variable that signals when some condition exists in the program.
a) flag
b) signal
c) sentinel
d) siren
23. A(n) __________ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.
a) sentinel
b) flag
c) signal
d) accumulator
24. The following is NOT an augmented assignment operator:
a) +=
b) -=
c) *=
d) ==
25. A count-controlled loop always repeats a specific number of times.
a) True
b) False
26. A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is __________.
a) code reuse
b) input validation
c) debugging
d) facilitation of teamwork
27. Calling a function and defining a function mean the same thing.
a) True
b) False
28. In Python you cannot write functions that accept multiple arguments.
a) True
b) False
29. A statement in one function can access a local variable in another function.
a) True
b) False
30. A function in Python can return more than one value.
a) True
b) False
31. Which function in the math module will round up to 4?
a) round(3.14)
b) int(3.14)
c) math.ceil(3.14)
d) math.floor(3.14)
32. Before a file can be used by a program, it must be
a) formatted
b) encrypted
c) closed
d) opened
33. When a program is finished using a file, it should do this.
a) erase the file
b) open the file
c) close the file
d) encrypt the file
34. When an exception is generated, it is said to have been __________.
a) built
b) raised
c) caught
d) killed
35. This is a section of code that gracefully responds to exceptions.
a) exception generator
b) exception manipulator
c) exception handler
d) exception monitor
36. You write this statement to respond to exceptions.
a) run/handle
b) try/except
c) try/handle
d) attempt/except
37. When you open a file that already exists on the disk using the 'w' mode, the contents of the existing file will be erased.
a) True
b) False
38. If you do not handle an exception, it is ignored by the Python interpreter, and the program continues to execute.
a) True
b) False
39. You can have more than one except clause in a try/except statement.
a) True
b) False
40. The else suite in a try/except statement executes only if a statement in the try suite raises an exception.
a) True
b) False
41. The following statement can cause an exception: names_file = open('names.txt', '
a) True
b) False
42. This term refers to an individual item in a list.
a) element
b) bin
c) array
d) slot
43. This is a number that identifies an item in a list.
a) element
b) index
c) bookmark
d) identifier
44. This is the first index in a list.
a) -1
b) 1
c) 0
d) The size of the list minus one
45. This is the last index in a list.
a) 1
b) 99
c) 0
d) The size of the list minus one
46. This will happen if you try to use an index that is out of range for a list.
a) A ValueError exception will occur.
b) An IndexError exception will occur.
c) The list will be erased and the program will continue to run.
d) Nothing - the invalid index will be ignored.
47. This function returns the length of a list.
a) length
b) size
c) len
d) lengthof
48. This list method adds an item to the end of an existing list.
a) add
b) add_to
c) increase
d) append
49. This file object method returns a list containing the file's contents.
a) to_list
b) getlist
c) readline
d) readlines
50. Lists in Python are immutable.
a) True
b) False
51. Tuples in Python are immutable.
a) True
b) False
52. A file object's writelines method automatically writes a newline ('\n') after writing each list item to the file.
a) True
b) False
53. You can use the + operator to concatenate two lists.
a) True
b) False
54. A list can be an element in another list.
a) True
b) False
55. Given the following Python code, what will the data type of pet be?
pet = "Gordon", "Gecko", 3
a) string
b) list
c) tuple
d) undefined
56. This is the first index in a string.
a) -1
b) 1
c) 0
The size of the string minus one
57. This is the last index in a string.
a) 1
b) 99
c) 0
d) The size of the string minus one
58. This will happen if you try to use an index that is out of range for a string.
a) A ValueError exception will occur.
b) An IndexError exception will occur.
c) The string will be erased and the program will continue to run.
d) Nothing - the invalid index will be ignored.
59. This function returns the length of a string.
a) length
b) size
c) len
d) lengthof
60. This operator determines whether one string is contained inside another string.
a) contains
b) is_in
c) ==
d) in
61. This string method returns true if a string contains only alphabetic characters and is at least one character in length.
a) isalpha()
b) alpha()
c) alphabetic()
d) isletters()
62. This string method returns true if a string contains only numeric digits and is at least one character in length.
a) digit()
b) isdigit()
c) numeric()
d) isnumber()
63. You can use the for loop to iterate over the individual characters in a string.
a) True
b) False
64. The isupper method converts a string to all uppercase characters.
a) True
b) False
65. The repetition operator (*) works with strings as well as with lists.
a) True
b) False
66. You can use the __________ operator to determine whether a key exists in a dictionary.
a) &
b) in
c) ^
d) ?
67. You use __________ to delete an element from a dictionary.
a) the remove method
b) the erase method
c) the delete method
d) the del statement
68. The __________ function returns the number of elements in a dictionary:
a) size()
b) len()
c) elements()
d) count()
69. You can use __________ to create an empty dictionary.
a) {}
b) ()
c) []
d) empty()
70. The __________ method returns a randomly selected key-value pair from a dictionary.
a) pop()
b) random()
c) popitem()
d) rand_pop()
71. The __________ method returns the value associated with a specific key and removes that key-value pair form the dictionary.
a) pop()
b) random()
c) popitem()
d) rand_pop()
72. The __________ dictionary method returns the value associated with a specified key. If the key is not found, it returns a default value.
a) pop()
b) key()
c) value()
d) get()
73. When an object is __________, it is converted to a stream of bytes that can easily be stored in a file for later retrieval.
a) defined
b) serialized
c) set
d) iterated over
74. The __init__ method is called automatically when __________.
a) a module is imported
b) a class is defined
c) a function is defined
d) an object is created
75. What is encapsulation?
a) a module used to serialize data
b) the combining of data and code into a single object
c) the process of indenting and formatting code
d) a structure used to iterate over data