What if statement would print the word "teenager" if the variable age is greater than or equal to 13?
Front
if age >= 13:
print("teenager")
or
if age > 12:
print("teenager")
Back
asparagus = "yes"
broccoli = "no"
Does the following control expression simplify to true or false?
asparagus == "no"
Front
false
since
asparagus == "no"
can be rewritten as
"yes" == "no"
which simplifies to
false
Back
4 + 2 ** 3
Front
12
since
4 + 2 ** 3
= 4 + 8
= 12
Back
What is the output?
grade = 85
if grade > 70:
if grade > 80:
print("great")
else:
print("ok")
else:
print("poor")
Front
great
Back
What are the 5 steps of the Programming Process in order?
Front
1. Understand 2. Design/Plan 3. Code 4. Test/Debug 5. Document
You should be able to explain them in a complete sentences as well!
Back
misspelling a ______________ such as immport causes a syntax error
Front
keyword
Back
What is the output?
grade = 95
if grade >= 90:
print("A")
if grade >= 80:
print("B")
Front
A
B
Both display since two if statements are independent of each other. That is, a single if elif statement was not used.
Back
What line of code sets the variable firstName to the actual first name of our first U.S. president?
Front
firstName = "George"
Back
asparagus = "yes"
broccoli = "no"
Does the following control expression simplify to true or false?
not (asparagus == "no" and broccoli == "no")
Front
true
since
not (asparagus == "no" and broccoli == "no")
can be rewritten as
not ("yes" == "no" and "no" == "no")
which simplifies to
not (false and true)
which simplifies further to
not (false)
which simplifies even further to
true
Back
7 // 3
Front
2
since 7 divided by 3 is 2.3333 but the .3333 is truncated or cut off since the // integer division operator is used rather than the / division operator
Back
foo = 6
num = 25
other = 9
Does the following control expression simplify to true or false?
num > 0 or (foo < 5 and other == 9)
Front
true
since
num > 0 or (foo < 5 and other == 9)
can be rewritten as
25 > 0 or (6 < 5 and 9 == 9)
which is
true or (false and true)
which simplifies further to
true or false
which simplifies even further to
true
Back
Documentation and notes that are only intended for human computer programmers to read and that are not executed by the computer are known as ____________.
Front
comments
Back
asparagus = "yes"
broccoli = "no"
Does the following control expression simplify to true or false?
broccoli != "yes"
Front
true
since
broccoli != "yes"
can be rewritten as
"no" != "yes"
which simplifies to
true
Back
The int function can convert a string to an ____________ as in this example:
age = int(input("Enter your age: "))
Front
integer
or
number
Back
The first step of the Programming Process is to _______________ the problem.
Front
understand
Back
-1 * (3 + 10)
Front
-13
since
-1 * (3 + 10)
= -1 * 13
= -13
Back
What line of code sets the variable votingAge to the integer value that is the U.S. voting age?
Front
votingAge = 18
Back
foo = 6
Does the following control expression simplify to true or false?
foo <= 6
Front
true
since
foo <= 6
simplifies to
6 <= 6
which further simplifies to
true
Back
What is the output?
grade = 75
if grade > 70:
if grade > 80:
print("great")
else:
print("ok")
else:
print("poor")
Front
ok
Back
What is the output of the following code segment?
width = 8
base = 4
height = 8
print(width / base * height)
Front
16
since
width / base * height
= 8 / 4 * 8
= 2 * 8
= 16
Note that the division is performed before multiplication from left to right according to PEMDAS.
Back
What statement must be used at the top of a program to produce turtle graphics?
Front
import turtle
Back
What is the output?
grade = 90
if grade >= 90:
print("A")
elif grade >= 80:
print("B")
Front
A
Back
200 % 10
Front
0
since 0 is the remainder of 200 divided by 10
Back
The variable data type used to store text (and also enjoyed by playful kittens) is _____________.
Front
string
Back
What if statement would print the phrase "movie ticket" if the variable age is equal to 13 and the variable money is greater than 12.
Front
if age == 13 and money > 12:
print("movie ticket")
Back
The % operator (symbol) is used to compute the ____________ of one integer divided by another integer. For example, 10 % 3 is 1.
Front
remainder
Back
What is the output?
grade = 85
if grade >= 90:
print("A")
elif grade >= 80:
print("B")
Front
B
since grade >= 90 simplifies
to
85 >= 90
which is false
so the elif control expression is checked and
grade >= 80
simplifies to
85 >= 80
which simplifies to
true
and therefore print("B") executes
Back
Debugging a program is done during the __________ step of the Programming Process.
Front
4th
Back
What line of code changes the color of a turtle named pen to the color of blue?
Front
pen.color("blue")
Back
The set of rules that determines the priority in which expressions with several operators such as multiplication ( * ) and addition ( + ) is known as the _________________.
Front
order of operations
or
PEMDAS
or
GEMDAS
Back
asparagus = "yes"
broccoli = "no"
Does the following control expression simplify to true or false?
asparagus == "yes" and broccoli == "yes"
Front
false
since
asparagus == "yes" and broccoli == "yes"
can be rewritten as
"yes" == "yes" and "no" == "yes"
which simplifies to
true and false
which simplifies even further to
false
Back
The expression 2 - 4 + 2 simplifies to ____________
Front
0
Note: The subtraction comes first according to PEMDAS since it appears before addition from left to right.
Back
What keyword is used to create a function?
Front
def
Back
What lowercase letter is displayed on the turtle graphic coordinate window?
import turtle
pen = turtle.Turtle()
pen.goto(0, 100)
pen.goto(0, 50)
pen.goto(50, 50)
pen.goto(50, 0)
Front
h
Back
How many parameters (numbers) does the goto function have in its parentheses? example: pen.goto( ??? )
Front
2
example: pen.goto(100, 0)
Back
What if statement would print the word "true" if the variable num is equal to 6?
Front
if num == 6:
print("true")
Back
pen
Front
Back
What is the output of the following code segment?
hours = 40
rate = 10.99
print(hours * int(rate))
Front
400
since
hours * int(rate)
= 40 * int(10.99)
= 40 * 10
= 400
Note that the int function truncates (cuts off) the decimal places of 10.99. It does not round 10.99 up to 11!
Back
A reserved word in a computer language such as Python that cannot be used as the name of a variable or function is a ___________.
Front
keyword
Back
What is the output of the following code segment?
a = "19"
b = "610"
c = a + b
print(c)
Front
19610
or
"19610"
since
a + b
is
"19" + "610"
and string concatenation occurs rather than mathematical addition. Note that 629 does NOT display since a and b are both strings with quotes around them.
Back
6 10 * (16 % 5)
Front
60
since
6 10 * (16 % 5)
= 6 10 * 1
= 6 * 10
= 60
Back
Is a vertical or horizontal line displayed by this code segment?
import turtle
pen = turtle.Turtle()
pen.left(90)
pen.penup()
pen.forward(50)
pen.right(90)
pen.forward(100)
Front
horizontal
Back
What is the output?
grade = 95
if grade >= 80:
print("B")
elif grade >= 90:
print("A")
Front
B
A logic error occurs since the grade >= 80 control expression is first checked and, since it is true, "B" is immediately printed!
Back
What number would make the line that connects these two points on a turtle coordinate grid a vertical line?
( _____ , 0) & (40, 100)
Front
40
Back
asparagus = "yes"
broccoli = "no"
Does the following control expression simplify to true or false?
asparagus == "yes" or broccoli == "yes"
Front
true
since
asparagus == "yes" or broccoli == "yes"
can be rewritten as
"yes" == "yes" or "no" == "yes"
which simplifies to
true or false
which simplifies even further to
true
Back
The str function can convert an integer to a ___________ as in this example:
age = 15
print("My age is " + str(age))
Front
string
Back
The # operator (symbol) is used to make a _________________ .
Front
comment
or
comment statement
Back
14 % 4
Front
2
since the remainder of 14 divided by 4 is 2
Back
24 2 + 3 * 2
Front
57
since
24 2 + 3 * 2
= 24 * 2 + 9
= 48 + 9
= 57
Back
Section 2
(3 cards)
Which section of a Python program comes first: constants or functions?
Front
constants
Back
Which section of a Python program comes first: constants or variables?
Front
constants
Back
Which section of a Python program comes last: main program or functions?