1/405
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Who developed the Python programming language?
A) Bjarne Stroustrup
B) Guido van Rossum
C) Yukihiro Matsumoto
D) James Gosling
B) Guido van Rossum
Python is a general-purpose programming language, appropriate for solving problems in many areas of computing.
A) True
B) False
A) True
The Python programming language was so named after a snake was discovered in the creator's office.
A) True
B) False
B) False
Python 3 is backwards compatible to Python 2.
A) True
B) False
B) False
Python embodies elements of which programming paradigm?
A) Procedural programming
B) Object-oriented programming
C) Functional programming
D) All of the above
D) All of the above
Which of the following is NOT a principle embraced by the Python programming language?
A) Complex is better than complicated.
B) Explicit is better than implicit.
C) Readability counts.
D) Simple is better than complex.
E) Beautiful is better than ugly.
F) Verbose is better than succinct.
F) Verbose is better than succinct
A Python program must be enclosed in curly braces { } to be executed.
A) True
B) False
B) False
Which of the following statements is true?
A) The print statement is a call to a function.
B) The print statement sends text output to a printer.
C) The print statement sends text output to the editor.
D) A print statement must be the first statement in a Python program
A) The print statement is a call to a function
A Python program must compiled into an executable form before it can be run.
A) True
B) False
B) False
What is syntax coloring?
A) Displaying program output in particular colors
B) Showing certain elements of program code in different colors
C) Wrapping program output in colored boxes
D) Displaying each method of a program in a different color
B) Showing certain elements of program code in different colors
What does the term case sensitive mean?
A) A Python program must be encased in a human-readable comment.
B) The difference between uppercase and lowercase letters matters.
C) A Python program is enclosed in, and executed relative to, a program case.
D) Each case of a Python print statement must be unique.
B) The difference between uppercase and lowercase letters matters
Thonny is best described as which of the following?
A) Debugger
B) Command shell
C) Package manager
D) Text editor
E) Integrated Development Environment (IDE)
E) Integrated Development Environment (IDE)
The output of a Python program run in Thonny appears in the shell window.
A) True
B) False
A) True
Thonny displays code using syntax highlighting.
A) True
B) False
A) True
Running a program that contains errors will cause the Thonny development environment to terminate.
A) True
B) False
B) False
Thonny has a package manager that lets you install and update external Python packages.
A) True
B) False
A) True
Python variables are created using an assignment statement.
A) True
B) False
A) True
The value of a variable can change throughout a program.
A) True
B) False
A) True
Which of the following is NOT a valid Python identifier?
A) FIRST_PLACE
B) 1stPlace
C) first_place
D) place1
B) 1stPlace (identifiers cannot begin w a digit)
Which of the following identifiers follows the convention for naming Python variables?
A) Total_Value
B) TOTAL_VALUE
C) totalValue
D) total_value
D) total_value
In dynamically typed languages, variables are declared to store a specific type of data.
A) True
B) False
B) False
Python variables that represent integers are NOT object reference variables.
A) True
B) False
B) False
The assignment operator has higher precedence than the arithmetic operators.
A) True
B) False
B) False
What value is assigned to the variable num by the following statement if the current value of num is 4? num = num * 2
A) 2
B) 4
C) 6
D) 8
D) 8
The value assigned to a variable must be numeric.
A) True
B) False
B) False
In Python, the assignment statement is also an expression.
A) True
B) False
B) False
The value assigned to a variable could be a floating point number.
A) True
B) False
A) True
What output does the following code produce?print('apple', 'banana')
A) applebanana
B) apple
banana
C) apple banana
D) apple, banana
C) apple banana (The print function separates its output by a space by default)
What output is produced by the following code?print(15 + 30)
A) 45
B) 45.0
C) "1530"
D) 1530
A) 45
What output does the following code produce?print('Ready', end=' ') print('Set', end='') print('Go')
A) Ready
SetGo
B) Ready SetGo
C) Ready
Set Go
D) Ready Set Go
B) Ready SetGo (The end argument is a space in the first call and the empty string in the second call)
What output is produced by the following code?print('Jan', 'Feb', 'Mar', sep='-')
A) Jan-Feb-Mar
B) Jan- Feb- Mar-
C) Jan - Feb - Mar
D) Jan-Feb-Mar-
A) Jan-Feb-Mar (Each value printed is separated by a dash)
What output is produced by the following code?print('oak', 'elm', 'pine', end='!', sep='#')
A) oak#elm#pine!
B) oak#! elm#! pine#!
C) oak#!elm#!pine!
D) oak!elm!pine#
A) oak#elm#pine! (Each value printed is separated by a # and the output ends with a !)
What is the Python shell?
A) An integrated development environment for developing Python programs.
B) An alternative to IDLE or Thonny.
C) A window in which Python statements and expressions are executed immediately.
D) A help system for Python programming.
C) A window in which Python statements and expressions are executed immediately
The Python shell is great for exploring Python language features.
A) True
B) False
A) True
You must use a print statement to display the result of an expression in the Python shell.
A) True
B) False
B) False
You can store a value in a variable in the Python shell.
A) True
B) False
A) True
The Python shell has an integrated help system.
A) True
B) False
A) True
What operator is used to perform string concatenation in Python?
A) *
B) &
C) @
D) +
D) +
What output does the following code produce?print('Total: ' + 100 + 20)
A) Total: 120
B) Total: 10020
C) Total: 1000200
D) No output. This line would produce an error.
D) No output. This line would produce an error (You can't concatenate a string and an integer in Python)
What issue must be addressed when printing a long character string?
A) The string must be subdivided into sections of 50 characters or less.
B) A regular string literal cannot span across multiple lines.
C) The print method has a maximum number of characters it can accept.
D) The print method cannot print character strings.
B) A regular string literal cannot span across multiple lines
If a variable called pioneer refers to the string 'Grace Murray Hopper', what is the result of the expression len(pioneer)?
A) 17
B) 18
C) 19
D) 20
C) 19 ( The len built-in function returns the number of characters in the string)
If a variable called business refers to the string 'Time Warner', what is the result of the expression business[6]?
A) ' '
B) 'r'
C) 'a'
D) 'W'
C) 'a' (string indexes start at 0)
If a variable called son refers to the string 'Justin', what is the result of the expression son[-3]?
A) 'tin'
B) 's'
C) 't'
D) The expression will generate an interpreter error
C) 't'
You cannot change the contents of Python character string once it has been created.
A) True
B) False
A) True (python strings are immutable)
If a variable called jedi refers to the string 'Yoda', what is the result of the expression jedi * 3?
A) YodaYodaYoda
B) YYYooodddaaa
C) 12
D) The expression will generate an interpreter error.
A) YodaYodaYoda
What is the Python Standard Library?
A) A set of officially sanctioned books about Python.
B) The set of documents that define the Python language.
C) A collection of software tools that support the development of Python programs.
D) A collection of programming components that can be used in any Python program.
D) A collection of programming components that can be used in any Python program
Using components from the Python Standard Library is a rare occurrence.
A) True
B) False
B) False
Built-in functions of the Python Standard Library can be used without being imported.
A) True
B) False
A) True
Full documentation about the Python Standard Library can be found online.
A) True
B) False
A) True
The Python turtle graphics module is based on the programming language Logo developed in the 1960s.
A) True
B) False
A) True
If the turtle is currently facing up (north), which way would it be facing after executing the command turtle.right(45)?
A) left (west)
B) up and left (northwest)
C) down and right (southeast)
D) right (east)
E) down and left (southwest)
F) up and right (northeast)
F) up and right (northeast). (The command turns the turtle 45 degrees to the right)
The pen color and size determines the color and width of the lines drawn.
A) True
B) False
A) True
The effect of the setheading depends on the current heading of the turtle.
A) True
B) False
B) False (When setting the heading explicitly, the current heading doesn't matter.)
Which way would the turtle be facing after executing the command turtle.setheading(135)?
A) down and left (southwest)
B) up and left (northwest)
C) left (west)
D) right (east)
E) down and right (southeast)
F) up and right (northeast)
B) up and left (northwest). (The heading angle is based on 0 degrees, which is to the right (east).)
Which way would the turtle be facing after executing the following code?turtle.setheading(270) turtle.right(20) turtle.left(65)
A) down and left (southwest)
B) down (south)
C) down and right (southeast)
D) up and left (northwest)
E) up and right (northeast)
F) up (north)
C) down and right (southeast). (after facing down, it turns to the southwest slightly, then back to southeast)
The position of a circle depends on the current heading of the turtle.
A) True
B) False
A) True
The turtle circle command can be used to draw a regular polygon.
A) True
B) False
A) True (The optional parameter steps determines how many sides the approximating polygon will have.)
The origin point (0, 0) of the turtle coordinate system is in the upper left corner of the graphic screen.
A) True
B) False
B) False (origin point is in center of screen)
The goto command moves the turtle without drawing a line.
A) True
B) False
B) False (It will draw a line if the turtle's pen is lowered.)
A turtle draws a filled circle using the fill_circle command.
A) True
B) False
B) False
The stroke color of a filled turtle shape must be the same as the fill color.
A) True
B) False
B) False
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.
A) True
B) False
A) True
Setting the turtle's speed to 0 turns off the animation of the turtle movement completely.
A) True
B) False
A) True
If either or both operands to the division operator (//) are floating-point values, then the result will be a floating-point value.
A) True
B) False
A) True
If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n.
A) True
B) False
B) False. (It will produce a result in the range 0 to n-1)
The expression x ^ y raises the value x to the power y.
A) True
B) False
B) False (The Python exponentiation operator is **)
The math module contains a constant that represents the value pi to several digits.
A) True
B) False
A) True
What is the result of the expression 7 // 2?
A) 0
B) 1
C) 3
D) 3.5
C) 3
What is the result of the expression 43 % 5?
1) 3
2) 4
3) 8
4) 8.6
A) 3 (remainder of 3)
If the variable num contains a positive integer, what are the only two possible results of the expression num % 2?
A) 1 and 2
B) 0 and 2
C) -1 and 1
D) 0 and 1
D) 0 and 1. (2 either divides the number evenly or there is 1 left over)
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.
A) hours / 24 + 1
B) hours / 24
C) hours // 24
D) hours % 24
C) hours // 24
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
A) 2
B) 4
C) 6
D) 8
C) 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
A) 2
B) 3
C) 5
D) 6
D) 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
A) 2
B) 3
C) 6
D) 8
D) 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
A) 0.0
B) 0.5
C) 1.0
D) 1.5
B) 0.5
Which line of code is equivalent to the following?
depth += 50 * offset
A) depth = depth + (50 * offset)
B) depth = (depth + 50) * offset
C) offset = depth + (50 * offset)
D) offset = depth + 50 * offset
A) depth = depth + (50 * offset)
All mathematical functions in Python are part of the math module.
A) True
B) False
B) False
The math.pi constant represents pi to 15 decimal places.
A) True
B) False
A) True
What is the result of the expression max(6, 17)?
A) 0
B) 6
C) 17
D) 23
C) 17
What is the result of the expression math.pow(3, 3)?
A) 0
B) 6
C) 9
D) 27
D) 27 (3 to the power 3 is 27)
What is the result of the expression math.floor(12.843)?
A) 0
B) 10
C) 12
D) 13
C) 12
Which of the following does the input function NOT do when it is called?
A) Wait for the user to type information and press Enter.
B) Convert the user input to an integer.
C) Return the value typed by the user.
D) Print a message if provided.
B) Convert the user input to an interger
What is text that requests user input called?
A) cue
B) poll
C) prompt
D) solicitation
C) prompt
The input function always returns the read data as a character string.
A) True
B) False
A) True
The input, int, and float functions are all built-in functions.
A) True
B) False
A) True
The input function will produce an error if the value read is not numeric.
A) True
B) False
B) False. (It's type conversion functions such as int and float that produce an error if necessary.)
What will happen if the variable total has the value 5 when the following code is executed?
if total > 8:
print('collywobbles')
A) The word collywobbles is not printed and an exception is thrown.
B) The word collywobbles is not printed, but an error message is.
C) The word collywobbles is not printed and processing continues.
D) The word collywobbles is printed and then processing continues.
C) The word collywobbles is not printed and processing continues
Which value of num will cause the print statement in the following code to be executed?
if num < 15:
if num + 7 >= 20:
print('There you go!')
A) 5
B) 10
C) 13
D) 18
C) 13
What output is printed by the following code if it is executed when appetizer is 3 and entree is 12?
if appetizer > 1:
if entree < 7:
print('ketchup')
else:
print('mustard')
else:
if appetizer < 0:
print('mayonnaise')
else:
print('relish')
A) ketchup
B) mustard
C) mayonnaise
D) relish
E) salsa
F) None of the above
B) mustard
Which of the following statements is true?
A) An if statement must contain an else clause.
B) An if statement is an example of a repetition statement.
C) The statements in the body of an if must be indented.
D) The body of an if statement must be enclosed in braces.
C) The statements in the body of an if must be indented
Of the options given, what values of the variables height, size, and width would cause the following code to set the variable weight to 100?
if height < size:
weight = 50
if width < 20:
print('short')
else:
if width > 100:
weight = 100
println('tall')
A) height = 12, size = 20, width = 200
B) height = 20, size = 12, width = 90
C) height = 15, size = 10, width = 110
D) height = 15, size = 25, width = 50
C) height = 15, size = 10, width = 110
An if statement cannot have both an elif and an else clause.
A) True
B) False
B) False
The relational operators all return boolean results.
A) True
B) False
A) True
The result of a relational operator can be assigned to a variable.
A) True
B) False
A) True
The arithmetic operators have a lower precedence than the relational operators.
A) True
B) False
B) False
Which of the following is a relational operator?
A) not
B) <=
C) /
D) and
B) <=
Which of the following expressions could be used to determine if a is not less than b?
A) a >= b
B) a < b
C) a > b
D) a !< b
A) a >= b
In Python, the relational operators can be used to put character strings in alphabetical order.
A) True
B) False
A) True
The less than operator (<) should not be used to compare floating point values.
A) True
B) False
B) False (There's no problem using < or > to compare floating point values. The danger comes from comparing them for equality)
A character string can be used as the condition of an if statement.
A) True
B) False
A) True