Intro to Python Final Exam Review
False
Variable names are important because computers understand the meaning of names and change their value accordingly: True or False
8) List
Which of the following types are sequences:
B) string
Given the file named scores.txt with the following contents
"Captain America"
Given the following code what is the value of the following expression:
"Iron Man"
Given the following code what is the value of the following expression:
"Loki"
Given the following code what is the value of the following expression:
"Steve"
Given the following code what is the value of the following expression:
126
Given the following code what is the value of the following expression:
Raises an error
Given the following code what is the value of the following expression:
8) dict[True]
Given the following code which of the following are valid expressions:
String
Given the following dictionary what is the type of the key "Name"
String
Given the following dictionary what is the type of the key "Small?"
Integer
Given the following dictionary what is the type of the value associated with the key "Age"
String
Given the following dictionary what is the type of the value associated with the key "Name"
5) print_message(fix_capitalization(name))
Given the program below, which of the following lines of code will have the data flow correctly through both functions in order to print the message with the fixed capitalization?
2
How many branches does this code snippet have:
3
How many branches does this code snippet have:
False
Tuples are composed of key/value pairs: True or False
True
Unlike lists, tuples are immutable, meaning tuples cannot be changed after they are created: True or False
True
Variables change their value over time according to the instructions in a program: True or False
False
Variables in Python are used to solve for unknown values, like in Algebra: True or False
type
Classify the following as either a keyword, type, value, or built-in function: String
for loop
A control structure for performing actions on each element of a sequence
dictionary
A data structure for mapping keys to values
list
A data structure for storing elements in an ordered sequence
False
A for loop will process a file sentence-by-sentence: True or False
variable
A name that can be associated with a value
function
A reusable chink of code with inputs and outputs
program
A sequence of coded instructions that manipulate data inside a computer
file
A sequence of data stored in your computer's long term memory
integer
name = "Python" grade = 100.0 What type of data is: 1+1
type
A categorization of values of similar kinds that determines what you can do with the values
module
A collection of functions, classes, and variables available to be imported
if statement
A control structure for branching the execution of a program
string
A type that represents textual data
False
A while loop will always execute at least once: True or False
False
A while loop will execute once for each expression in the conditional: True or False
BankAccount
Choose which of the following are valid Python variable names. Note that they do not have to be goo variable names, just valid.
value
Classify the following as either a keyword, type, value, or built-in function: ""
value
Classify the following as either a keyword, type, value, or built-in function: 5
type
Classify the following as either a keyword, type, value, or built-in function: Boolean
type
Classify the following as either a keyword, type, value, or built-in function: Dictionary
type
Classify the following as either a keyword, type, value, or built-in function: Float
type
Classify the following as either a keyword, type, value, or built-in function: List
value
Classify the following as either a keyword, type, value, or built-in function: True
value
Classify the following as either a keyword, type, value, or built-in function: []
keyword
Classify the following as either a keyword, type, value, or built-in function: def
keyword
Classify the following as either a keyword, type, value, or built-in function: for
keyword
Classify the following as either a keyword, type, value, or built-in function: import
keyword
Classify the following as either a keyword, type, value, or built-in function: in
built-in function
Classify the following as either a keyword, type, value, or built-in function: input
type
Classify the following as either a keyword, type, value, or built-in function: integer
built-in function
Classify the following as either a keyword, type, value, or built-in function: print
keyword
Classify the following as either a keyword, type, value, or built-in function: return
keyword
Classify the following as either a keyword, type, value, or built-in function: while
value
Classify the following as either a keyword, type, value, or built-in function: {1:2}
False
Dictionaries are useful because you can have duplicate keys: True or False
False
Dictionaries cannot be composed of list values: True or False
False
Dictionaries will always have at least one key and one value: True or False
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": 3 < 5
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": " " in quote
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": "" in quote
False
Evaluate whether the following is True, False, or Error given quote = "I like turtles": "1" + "1" == "2"
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": "Alaska" < "Delaware"
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": "False" == "False"
False
Evaluate whether the following is True, False, or Error given quote = "I like turtles": "quote" in quote
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": "turtle" in quote
False
Evaluate whether the following is True, False, or Error given quote = "I like turtles": 10 == "10"
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": 10 == 10.0
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": 5 < 4 or 3 == 3
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": 5 in [1,3,5]
False
Evaluate whether the following is True, False, or Error given quote = "I like turtles": False
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": True or (True and False)
Error
Evaluate whether the following is True, False, or Error given quote = "I like turtles": [1,2,3] < 5
False
Evaluate whether the following is True, False, or Error given quote = "I like turtles": []
True
Evaluate whether the following is True, False, or Error given quote = "I like turtles": not False
False
Evaluate whether the following is True, False, or Error given quote = "I like turtles": not True and False
False
Every function created with the def keyword must have at least one parameter: True or False
False
Expressions are always evaluated from left to right: True or False
C) at least once
How many times does the loop body below execute:
2
How many values can be used at a time with each of the following operator: !=
2
How many values can be used at a time with each of the following operator: +
2
How many values can be used at a time with each of the following operator: and
1
How many values can be used at a time with each of the following operator: not
False
Humans discovered programming languages in the 1940s and have been decoding them ever since: True or False
9) Curly Brace
Identify each of the components of the Dictionary literal below:
C) Inside
Is the print call before, inside, or after the for loop:
True
Keys can be added to a dictionary after the dictionary has been created: True or False
Method call
Label the following as a function call, method call, or not a call: "function".method()
Not a call
Label the following as a function call, method call, or not a call: (input)
Not a call
Label the following as a function call, method call, or not a call: file.(close)
Method call
Label the following as a function call, method call, or not a call: function.call()
Function call
Label the following as a function call, method call, or not a call: method()
Function call
Label the following as a function call, method call, or not a call: print()
Read
Label the following as either a "Read", "Write", or "Read and Write" for the variable price: adjusted = price * tax
Write
Label the following as either a "Read", "Write", or "Read and Write" for the variable price: price = 0
Read and Write
Label the following as either a "Read", "Write", or "Read and Write" for the variable price: price = price * .9
Read
Label the following as either a "Read", "Write", or "Read and Write" for the variable price: print(price)
True
Like an if statement and a function call, the for loop might cause the execution to not follow the sequential order of lines: True or False
True
List comprehensions cannot express everything that a for loop can: True or False
True
Lists can be composed of dictionaries: True or False
True
Normally, statements are executed from top to bottom: True or False
False
Once a function returns a variable, that variable is available outside of the function: True or False
False
Printing is the same thing as returning: True or False
literal value
Specific instances of data written directly in source code
False
Strings are composed of only letters and symbols: True or False
False
The body of a for loop will contain one statement for each element of the iteration list: True or False
True
The given program does not correctly close the file:
Retrieves input from the user
The input function does which of the following:
True
The iteration variable will take on each value of the list variable, one at a time: True or False
False
The open function consumes a string representing a path and returns a string of the file's contents: True or False
False
The print function can only print literal values: True or False
Consumes arguments
The print function does which of the following:
False
The print function is necessary to call a function: True or False
False
The statement count = count + 1 will cause an error because no number can be greater than itself: True or False
A) Absolutely nothing
What does the pass function do:
E) Dictionary
What is the type of the iteration variable in this code:
A) No value, because an error occurs since the value has not been defined
What is the value of tax after this program executes:
string
What type of data is: "2.0"
string
What type of data is: "Python"
string
What type of data is: "True"
string
What type of data is: ''
tuple
What type of data is: (1,2,3)
float
What type of data is: -1.4
integer
What type of data is: -100000257
integer
What type of data is: 5
None
What type of data is: None
Boolean
What type of data is: True
list
What type of data is: [1,2,3]
list
What type of data is: []
dictionary
What type of data is: {1:2}
dictionary
What type of data is: {}
The distribution through a set of data
What type question is the following type of graph most suited to:
The relationship between 2 sets of data
What type question is the following type of graph most suited to:
The trend in a set of data
What type question is the following type of graph most suited to:
A) 3
What will be printed after this code is run:
D) None
When the following code is executed, what will be the value of the variable named greeting?
5) String
Which of the following are possible subtypes for a list:
Other Expressions
Which of the following can be involved in an expression:
A) a_dictionary["Key"]
Which of the following demonstrates proper syntax for accessing a dictionary's value:
4) "How do I update a variable?"
Which of the following email titles are good titles when seeking help from a senior colleague:
A) month, year = (11,17)
Which of the following expressions creates two new variables?
6) if statement
Which of the following have a body?
B) loads the sqrt function in the math module but renames it square_root
Which of the following is the best description of this line of code?
json.load(file)
Which of the following two snippets of code are equal:
False
You can nest if statements inside of other if statements, but not inside functions: True or False
True
You must import the json module before you can use the load function: True or False
False
You should not put error messages into help seeking emails because it can clutter up the email: True or False
float
name = "Python" grade = 100.0 What type of data is: 4/5
integer
name = "Python" grade = 100.0 What type of data is: [0][0]
list
name = "Python" grade = 100.0 What type of data is: [name]
dictionary
name = "Python" grade = 100.0 What type of data is: {name: grade}
Boolean
name = "Python" grade = 100.0 What type of data is: True or False
string
name = "Python" grade = 100.0 What type of data is: name[0]
float
name = "Python" grade = 100.0 What type of data is: grade - grade
string
name = "Python" grade = 100.0 What type of data is: "1"+"1"
list
name = "Python" grade = 100.0 What type of data is: "1,2,3,4".split(",")
boolean
name = "Python" grade = 100.0 What type of data is: 1 < 5.0
boolean
name = "Python" grade = 100.0 What type of data is: 1+1 < 5 or 4 > 3
integer
name = "Python" grade = 100.0 What type of data is: 100-99