WorksheetsPython Midterm Review
Total questions: 24
Worksheet time: 20mins
You are running a Python script that is supposed to write data to an open file, but discover that the file contents are being erased each time the script runs. What is most likely the issue?
The file was opened using a mode string other than 'a'.
The file is truncated by default with the write() method.
The file is erased when the script uses the close() method.
The file must be opened using a mode string of 'rw'.
What is the name used for the integrated program development environment that comes with a Python installation?
Eclipse
IDLE
PyShell
PyDDL
What term describes the process of substituting a simple process for a complex process in a program to make the program easier to understand and maintain?
refactoring
abstraction
recurision
instantation
You are running a Python script that is supposed to write data to an open file, but discover that the file contents are not updating even after the script finishes. What is most likely the issue?
The file was opened using 'w' instead of 'b' as the mode string.
The file is not being updated because it doesn't exist.
The file is not being written to using the dump() method.
The file was not closed using the close() method.
What list method should you use in order to remove and return the element at the end of the list named "books"?
books.get()
books.pop()
books.fetch()
books.pull()
In a computer, what component is known as the "processor"?
RAM
CPU
basic input/output devices
motherboard
What kind of programming language is Python?
An interpreted language.
A compiled language.
An interpolated language.
A manufactured language.
What must be done in order to concatenate a string and a float object?
Nothing can be done, as the two data types cannot be converted to a compatible type.
The string object must be converted to a float object via the float() function.
The float object must be converted to an integer object via the int() function.
The float object must be converted to a string object via the str() function.
When a sender of information encrypts that information, what is the resulting text known as?
plain text
garbage text
cipher text
junk text
When declaring a tuple, you enclose the tuple's elements in what two characters?
[ ]
( )
{ }
< >
An off-by-one error is an example of what type of error in programming?
logic
syntax
type
input
Python, what does the "%" operator do in the expression 6 % 4?
It performs an exponentiation to the 4th power.
It returns a float as a result of division.
It returns a remainder or modulus.
It returns the percentage of the operation.
What effect does the following print statement have? print("Hello" * 5)
The string "Hello" is converted into an int type of value 1 and then multiplied by 5, producing "5".
The string is indexed and the character count is multiplied with the total number of characters in the string, producing "25".
The print statement produces a type error as you cannot multiply a string type with an integer type.
The print statement will produce "HelloHelloHelloHelloHello".
What happens if you attempt to access a string using an index equal to the string's length?
The entirety of the string will be accessed.
The name of the string will be accessed.
The string's location in memory will be returned.
An error will occur, indicating the index is out of range.
The while loop is also known as what kind of a loop?
infinite loop
operational loop
user-control loop
entry-control loop
What file access method can be used to read a single line of input and return the line as a string, including the newline character?
getline
readline
fetch
read
When creating a list of items whose structure will not change, what should you ideally use to contain the values?
lists
tuples
dictionaries
strings
What happens if you use the following statement to sort a list of numbers called numbers? numbers = numbers.sort()
numbers is a value of None
The list is now ordered in ascending order.
The list is now ordered in descending order.
The numbers variable becomes a reference to a sorted list.
Pattern Recognition
Puzzle
Action
Strategy
Trivia
Reflexes(quick Movements)
Simulation
Strategy
Action
MMO
Resource Management
RPG
Adventure
MMO
Strategy
Name 3 factors that motivate people to play games. What motivates you to play games, and why?
Convert the following to a binary number: 85
Convert the following binary number to a decimal number"
100111
