WorksheetsCoding 1 Semester 1 review 2
Total questions: 25
Worksheet time: 15mins
What kind of data does an integer variable contain?
Whole numbers
Words
Numbers that can have a decimal
An integer is not a Python variable type
Choose the correct declaration of a float variable named pi with the value 3.14
pi = "3.14"
pi = int(3.14)
pi = 3.14
float pi = 3.14
Which of the following choices is a properly formed Python variable name, meaning it is both legal in the Python language and considered good style?
FirstName
first_name
fIrStNAme
!firstName
The ability to use code again and again is called:
Availability
Reusability
Abstraction
Mobility
What is the value of num after this code runs?
0
4
5
35
Which one of the statements below will cause an error?
ans = “hi” + 9
ans = “hi” + “hi” + “hi"
ans = 9 * (3 + 1) / 6
ans = “yes”
What is the output of the following function call?
0
4
24
48
Which mode do you want to read and write to a file, but not erase what is already in the file?
r
r+
w
w+
Where should the function definitions be in your code?
At the top, after imports
Anywhere, it doesn't matter
Just before where it is called
Just after where it is called
What is the value returned by the following function?
10
35
40
50
Which of the following choices is NOT a Python variable type?
int
str
float
number
A function definition must start with:
def
int
func
function
When a function sends something back to the main program, it uses a:
assignment
pass
return
transfer
Choose the option that correctly prints out the variable(s).
x = “hi”
print(int(x))
num = 8
print(“num”)
name = “Alyx”
age = 32
print(name + “ is “ + str(age))
language = “Python”
print(“I’m learning “ language)
Which line(s) of code will output 6 in the print statement?
I and III
I and IV
II and III
II and IV
Given this code, what would be the correct line of code to call the function and receive the returned variables.
nameAge(name, age)
print(nameAge())
name, age = nameAge()
name = age = nameAge()
What is the final result of the expression print(10 / 2 + 6)?
11.0
8.0
0
1.2
On which line of code will Python error?
Line 1
Line 2
Line 3
Line 4
Choose the print statement below that will cause an error. Assume that num=6, and name = "Isabella".
print (name + “wants ” + “num ” + “candies”)
print(name + “ wants ” + str(num) + “candies”)
print (name + “ wants ” + num + “candies”)
What is the output of this code:
iday
rida
ida
rid
When a function returns a value, what must be done with the value?
Assigned to a variable
Printed (called from a print statement)
Passed to another function
Any of these
The variables inside the parenthesis in a function definition are called
Parameters
Arguments
Local variables
Scope
The order in which lines of code are executed is called
Order of operations
Line execution
Flow of information
Flow of execution
Adding two strings together is called:
Addition
Concatenation
Line printing
Conversion
What is the output of this code?
Congratulations Bob, you are 15
Congratulations 15, you are Bob
No output because of an error
