stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Python Review Units 3-7 Flashcards | StudBud
Explore
/
Python Review Units 3-7
Python Review Units 3-7
20 terms
·
StudBud Administration
·
8 plays
Imported from external platform
Flashcards
20 cards
F
Practice quiz
P
Host live
L
Questions
20
Answers
1
Which of the following expressions will print “L”? word = "PINEAPPLE"
print(word[-3])
print(word[-2])
print(word[-1])
print(word[-4:])
2
Which statement returns control to the top of the loop?
if
break
continue
return
3
Which operator is used for exponentiation in Python?
**
*
^
//
4
What is the correct way to call a function named print_sum?
print_sum()
print_sum
def print_sum():
print_sum():
5
Which of the following for loops would print the following numbers?
for i in range(3, 10, 2): print i
for i in range(3, 9, 2): print i
for i in range(9): print i
for i in range(3, 9): print i
6
What is the
parameter
of the function quadrupleNumber?
println
none
x
quadX
7
When does a while loop stop executing?
both red and blue answers above are correct
After a "break" statement is seen.
When the corresponding conditional statement is false.
8
What does “immutable” mean with respect to Python strings?
the string’s value cannot be modified
anything can be changed
The variable cannot be assigned a new value
9
The following are two kinds of python loops...
while, break
while, for
if, then
while, if
10
What does defining a function do?
It erases a function.
It copies a function.
It executes (runs) the code within a function.
It creates a reusable block of code with a name.
11
Which of the following string operation is illegal? word = "music"
word[0] = "M"
word = word[2] + word[-1]
word = "musical"
word = word + "al"
12
If you know how many times you will execute a loop body, which type of loop should you use?
while
for
13
Question
: What data type is the result of the expression 5 / 2 in Python?
string
float
integer
14
Calling a function means to.....
copy the function
actually run the code
rewrite the function
write a function with all the code inside it
15
Why do we use loops in programming?
To repeat sections of code.
To break code into smaller pieces
To confuse programmers.
To do simple math problems
16
What does the following Python program print?
9
12
21
15
17
Which word is used for count-controlled loops in python?
for
elif
if
while
18
Can while loops go forever?
Yes
No
19
What is the correct order of the parameters for the "range" function?
step, start, stop
start, stop, step
stop, start, step
start, step, stop
20
True or False: A variable created within a function can be a global variable.
False
True