Python Final Exam ALL ANSWERS 100% CORRECT 2022-2023 LATEST SOLUTION
Who developed the Python programming language? - Guido van Rossum
T/F: Python
... [Show More] is a general-purpose programming language, appropriate for solving
problems in many areas of computing. - True (You might use Python for web
development, business applications, and artificial intelligence, among many others.)
T/F: The Python programming language was so named after a snake was discovered in
the creator's office. - False
T/F: Python 3 is backwards compatible to Python 2. - False
Python embodies elements of which programming paradigm? - Procedural
programming
Object-oriented programming
Functional programming
Which of the following is NOT a principle embraced by the Python programming
language? - Verbose is better than succinct
Thonny is best described as which of the following? - Integrated Development
Environment (IDE)
T/F: The output of a Python program run in Thonny appears in the shell window. - True
T/F: Thonny displays code using syntax highlighting. - True
T/F: Running a program that contains errors will cause the Thonny development
environment to terminate. - True
T/F: The Thonny debugger lets you trace the value of variables while your program is
executing. - True
T/F: A Python program must be enclosed in curly braces { } to be executed. - False
Which of the following statements is true? - The print statement is a call to a function
T/F: A Python program must compiled into an executable form before it can be run. -
False
What is syntax coloring? - Showing certain elements of a program code in different
colors
What does the term case sensitive mean? - The difference between uppercase and
lowercase letters matters
What output does the following code produce?
print('apple', 'banana') - apple banana
What output is produced by the following code?
print(15 + 30) - 45
What output does the following code produce?
print('Ready', end=' ')
print('Set', end='')
print('Go') - Ready SetGo
What output is produced by the following code?
print('Jan', 'Feb', 'Mar', sep='-') - Jan-Feb-Mar
What output is produced by the following code?
print('oak', 'elm', 'pine', end='!', sep='#') - oak#elm#pine!
T/F: Python variables are created using an assignment statement. - True
T/F: The value of a variable can change throughout a program. - True
Which of the following is NOT a valid Python identifier? - 1stPlace
Which of the following identifiers follows the convention for naming Python variables? -
total_value
T/F: In dynamically typed languages, variables are declared to store a specific type of
data. - False
T/F: Python variables that represent integers are NOT object reference variables. -
False
T/F: The assignment operator has higher precedence than the arithmetic operators. -
False
What value is assigned to the variable num by the following statement if the current
value of num is 4?
num = num * 2 - 8
T/F: The value assigned to a variable must be numeric. - False
In Python, the assignment statement is also an expression. - False
The value assigned to a variable could be a floating point number. - True
T/F: Python comments begin with a hash mark (#) and extend to the end of the line. -
True
T/F: A comment in a Python program is ignored by the interpreter. - True
T/F: A Python comment cannot appear on a line that contains an executable statement.
- False (helps explain it)
T/F: A Python block comment begins with a double slash (//). - False (starts with #)
What is a docstring? - A character string used as a comment in a program
T/F: If either or both operands to the division operator (//) are floating-point values, then
the result will be a floating-point value. - True
T/F: If both operands to the remainder operator (%) are positive, a divisor of n will
produce a result in the range 1 to n. - False (produce a range 0 to n-1)
T/F: The math module contains a constant that represents the value pi to several digits.
- True
What is the result of the expression 7 // 2? - 3
What is the result of the expression 43 % 5 - 3
If the variable num contains a positive integer, what are the only two possible results of
the expression num % 2? - 0 and 1
Suppose the integer variable hours contains a value that represents a number of hours.
Which of the following expressions will compute how many 24-hour periods are
represented by that value, without worrying about any leftover hours. - hours // 24
What is the Python Standard Library? - A collection of programming components that
can be used in any python program
T/F: Using components from the Python Standard Library is a rare occurrence. - False
T/F: Built-in functions of the Python Standard Library can be used without being
imported. - True
T/F: Full documentation about the Python Standard Library can be found online. - True
T/F: All mathematical functions in Python are part of the math module. - False (several
built-in functions)
T/F: The math.pi constant represents pi to 15 decimal places. - True
What is the result of the expression max(6, 17) - 17
What is the result of the expression math.pow(3, 3) - 27
What is the result of the expression math.floor(12.843) - 12
Why don't we use natural languages (like English) to program a computer? - Natural
languages are semantically ambiguous (have more than one meaning)
What is the syntax of a language? - The rules that determine how words and symbols
can be combined.
T/F: In a programming language, a syntactically valid statement has only one meaning.
- True
T/F: A program that runs without generating a runtime error will produce correct results.
- False
Which of the following would cause a syntax error? - Mispelling a word
Which of the following would cause a runtime error? - Diving by 0
Computing the wrong answer is an example of what kind of error? - Logic error
Debugging is the process of: - Finding the root cause of an error and fixing it.
If the current value of the variable num is 4, what value will be stored in num after the
following line of code is executed?
num += 2 - 6
If the current value of the variable size is 2, what value will be stored in size after the
following line of code is executed?
size *= 3 - 6
If the current value of the variable count is 2, what value will be stored in count after the
following line of code is executed?
count += count * 3 - 8
If the current value of the variable num1 is 2 and the current value of the variable num2
is 3, what value will be stored in num2 after the following line of code is executed?
num2 /= num1 * num2 - 0.5
Which line of code is equivalent to the following? depth += 50 * offset - depth = depth + (50 * offset)
T/F: The Python turtle graphics module is based on the programming language Logo
developed in the 1960s. - True
If the turtle is currently facing up (north), which way would it be facing after executing
the command turtle.right(45)? - up and right (northeast)
T/F: The pen color and size determines the color and width of the lines drawn. - True
T/F: The effect of the setheading depends on the current heading of the turtle. - False
Which way would the turtle be facing after executing the command
turtle.setheading(135)? - up and left (northwest)
Which way would the turtle be facing after executing the following code?
turtle.setheading(270)
turtle.right(20)
turtle.left(65) - down and right (southeast)
T/F: The position of a circle depends on the current heading of the turtle. - True
T/F: The turtle circle command can be used to draw a regular polygon. - True
T/F: The origin point (0, 0) of the turtle coordinate system is in the upper left corner of
the graphic screen. - False
T/F: The goto command moves the turtle without drawing a line. - False
T/F: A turtle draws a filled circle using the fill_circle command. - False (no such
command)
T/F: The stroke color of a filled turtle shape must be the same as the fill color. - False
T/F: If a filled shape drawn by a turtle is not fully enclosed, Python fills the shape as if
the starting point is connected to the end point. - True
T/F: Setting the turtle's speed to 0 turns off the animation of the turtle movement
completely. - True
Which of the following does the input function NOT do when it is called? - Convert the
user input to an integer.
What is text that requests user input called? - prompt
T/F: The input function always returns the read data as a character string. - True
T/F: The input, int, and float functions are all built-in functions. - True
T/F: The input function will produce an error if the value read is not numeric. - False (wil
produce error if int or float used)
What operator is used to perform string concatenation in Python? - + [Show Less]