PYTHON SYNTAX UPDATED EXAM QUESTIONS AND
CORRECT ANSWERS
Question 1
What is the value of total_cost that gets printed
Total_cost = 5
Total_cost += 10
Print (total cost)
Correct Answer
15
Question 2
What is the output of the following code
Cool_number = 12 + 30
Cool_number *5
Print (cool_number)
Correct Answer
42
Question 3
What happens when running the following code
Message = what a cool message !
Print (message)
Correct Answer
Python throws a syntax error because the string is not surrounded by quotes
Question 4
What number is saved to exponented_variable in the following expression
2 ** 4
Correct Answer
16
Question 5
This produces a SyntaxError
Correct Answer
Answer= "is this an error'
Page 1 of 167
,Question 6
How does one define a multi-line string in python
Correct Answer
"""
Like this
"""
Question 7
What character begins a comment in python
Correct Answer
#
Question 8
What is python syntax for creating a variable and setting it equal to the number 10
Correct Answer
Variable_name = 10
Question 9
What function outputs text to the terminal
Correct Answer
Print ()
Question 10
How do you combine two strings
Correct Answer
String1 + string2
Question 11
What is the difference between float and an int
Correct Answer
A float represents decimal quantities. An int represents whole numbers
Question 12
What is the value of modulo_variable in the following expression
Modulo_variable = 14%4
Correct Answer
2
Page 2 of 167
,Question 13
This defined variable is a string
Correct Answer
Cool_variable_3 = "important message!"
Question 1
In Python the way to get the computer to speak is by using the _____ statement
Correct Answer
print ststement
Question 2
There are two different Python versions Python 2 and Python. The most significant difference between the two is
how you write a PRINT statement. In Python 3, print has ?
Correct Answer
() parentheses example : print("Hello World!")
Question 3
A string in Python is
Correct Answer
a series of letters, numbers, or symbols connected in order
Question 4
A string can be defined in two ways but it needs to be closed by the same type of quote mark
Correct Answer
(''),(') double quotes and single quotes
Question 5
We can combine multiple strings by using the
Correct Answer
+ plus like so : print "This is " + "a good string"
Question 6
Try adding your name to the print statement with the + operator so that this Python program prints "Hello
[your_name]"
Correct Answer
print "Hello " + "Rico "
Page 3 of 167
, Question 7
Mismatched quotes will cause what error
example: print "Mismatched quotes will cause a'
Correct Answer
SyntaxError: EOL while scanning a string literal. This mean that the string wasn't closed with the same quote-
character that staryed it
Question 8
Without quotes will cause a
Correct Answer
NameError This means that Python found what it thinks is a command, but doesn't know what it means because
it's not defined anywhere
Question 9
Python uses what to define things that are subject to change.
Correct Answer
Variables
Question 10
Create a variable called 'todays_date" and assign a value that will represent today's date to that variable.
Correct Answer
todays_date = "12/14/2021"
Question 11
Example of Python Arithmetic
Correct Answer
mirthful_addition = 12381 + 91817
amazing_subtraction = 981 -312
trippy_multiplication = 38 * 902
happy_division =
sassy_combinations = 129 * 1345 + -12
Question 12
Python also offers a companion to division called the modulo operator. The modulo operator is indicated by _____
and returns the remainder after division is performed.
Correct Answer
% percentage sign
Question 13
Multiply two numbers together and assign the results to a variable called product
Correct Answer
product = 2 * 2
Page 4 of 167
CORRECT ANSWERS
Question 1
What is the value of total_cost that gets printed
Total_cost = 5
Total_cost += 10
Print (total cost)
Correct Answer
15
Question 2
What is the output of the following code
Cool_number = 12 + 30
Cool_number *5
Print (cool_number)
Correct Answer
42
Question 3
What happens when running the following code
Message = what a cool message !
Print (message)
Correct Answer
Python throws a syntax error because the string is not surrounded by quotes
Question 4
What number is saved to exponented_variable in the following expression
2 ** 4
Correct Answer
16
Question 5
This produces a SyntaxError
Correct Answer
Answer= "is this an error'
Page 1 of 167
,Question 6
How does one define a multi-line string in python
Correct Answer
"""
Like this
"""
Question 7
What character begins a comment in python
Correct Answer
#
Question 8
What is python syntax for creating a variable and setting it equal to the number 10
Correct Answer
Variable_name = 10
Question 9
What function outputs text to the terminal
Correct Answer
Print ()
Question 10
How do you combine two strings
Correct Answer
String1 + string2
Question 11
What is the difference between float and an int
Correct Answer
A float represents decimal quantities. An int represents whole numbers
Question 12
What is the value of modulo_variable in the following expression
Modulo_variable = 14%4
Correct Answer
2
Page 2 of 167
,Question 13
This defined variable is a string
Correct Answer
Cool_variable_3 = "important message!"
Question 1
In Python the way to get the computer to speak is by using the _____ statement
Correct Answer
print ststement
Question 2
There are two different Python versions Python 2 and Python. The most significant difference between the two is
how you write a PRINT statement. In Python 3, print has ?
Correct Answer
() parentheses example : print("Hello World!")
Question 3
A string in Python is
Correct Answer
a series of letters, numbers, or symbols connected in order
Question 4
A string can be defined in two ways but it needs to be closed by the same type of quote mark
Correct Answer
(''),(') double quotes and single quotes
Question 5
We can combine multiple strings by using the
Correct Answer
+ plus like so : print "This is " + "a good string"
Question 6
Try adding your name to the print statement with the + operator so that this Python program prints "Hello
[your_name]"
Correct Answer
print "Hello " + "Rico "
Page 3 of 167
, Question 7
Mismatched quotes will cause what error
example: print "Mismatched quotes will cause a'
Correct Answer
SyntaxError: EOL while scanning a string literal. This mean that the string wasn't closed with the same quote-
character that staryed it
Question 8
Without quotes will cause a
Correct Answer
NameError This means that Python found what it thinks is a command, but doesn't know what it means because
it's not defined anywhere
Question 9
Python uses what to define things that are subject to change.
Correct Answer
Variables
Question 10
Create a variable called 'todays_date" and assign a value that will represent today's date to that variable.
Correct Answer
todays_date = "12/14/2021"
Question 11
Example of Python Arithmetic
Correct Answer
mirthful_addition = 12381 + 91817
amazing_subtraction = 981 -312
trippy_multiplication = 38 * 902
happy_division =
sassy_combinations = 129 * 1345 + -12
Question 12
Python also offers a companion to division called the modulo operator. The modulo operator is indicated by _____
and returns the remainder after division is performed.
Correct Answer
% percentage sign
Question 13
Multiply two numbers together and assign the results to a variable called product
Correct Answer
product = 2 * 2
Page 4 of 167