What Are The 4 Parts of a While Loop?
Identify Loop Var, Initialize Loop Var, Condition While Loop, Update Loop Var
print(10 / 0)
Is an example of?
Traceback error
(cannot divide by zero)
if x > 5
print("x is greater than 5")
is an example of...
Syntax Error
What should be implemented in any code to perform iteration?
A loop
T or F:
A while loop will continue to iterate forever unless it meets a condition to stop.
True
This keyword is used to define a function.
def
This type can return True or False statements...
bool
The keyword used to check that a condition has been deemed True
if
What built in function is used to add an item to the end of a list?
append()
Len() or Length
How would you convert a string to all be uppercase?
.upper()
What is wrong with this code
s = 'Phantom Opera'
index = len(s)-1
while index >= 0
print(chr(ord(s[index])+1),end='')
index -= 1
while index >= 0:
How can your program exit a loop before it finishes iterating?
Break
How can you get an input from a user in a python program?
input()
Is this variable correct?
2DiskMove = print("Hello world!")
No!
for i in range(1, 6):
print(i * 2)
What does the following code output?
2
4
6
8
10
What is the one statement that Dr.Rasamny apparently hates to see in code.
Break
When // that is seen in code what does it mean happens in the line of code.
It gives the answer to a division problem without a remainder.
my_list = [2, 0, 3, 4, 5, 6, 7]
Reorder this list to look like this [0, 1, 2, 3, 4, 5, 6, 7, 8] and all changes to this list must be permanent and be imbedded in the list.
my_list.append(8)
my_list.insert(0,1)
my_list.sort()
What is a dictionary in python?
A dictionary in Python is a built-in data structure that stores data in key-value pairs. Each key is unique and maps to a specific value, making dictionaries highly efficient for data retrieval.
What function must be used to take the string 'venture' out of the variable jake_dog.
jake_dog = 'adventure'
jake_dog[2:]
cool_ranch = 20
for i in range(5):
if cool_ranch % 3 == 0:
cool_ranch = cool_ranch - 5
else:
cool_ranch = cool_ranch + 2
What is the final value of cool_ranch?
cool_ranch = 16
life = 50
saver = 5
while life >= saver:
life = life // saver
saver = saver + 1
What are the final values of life, saver, and (life < saver)? True or False?
life = 1
saver = 7
(life < saver) = True
logi = 18
dell = 2
while not (logi <= dell):
logi = logi - dell * 2
dell = dell * 3
What are the final values of logi and dell?
logi = 2
dell = 18
pro = 15
app = 0
tut = 4
while not (pro < tut):
pro = pro - tut
app = app + 2
pro = 3
app = 6
tut = 4
(pro < tut) = True