What is “def”
Loop that runs a predetermined number of times
What is for loop
Function to get the length of a list or a string
What is len
Comment line starts with this character
What is #
Function to display a string on screen
What is print
loop that runs as long as the condition is true
What is while loop
This type of bracket defined a list
What is square brackets []
The following will print a line showing the number 4:
for i in range(4):
print(i)
What is false
Function to convert a number to a string
What is str
Keyword to get out of a loop
What is break
The index of the first element of a list
What is 0
Which of the following operators is used for equality comparison in Python?
A
==
B
=
C
===
D
>
What is A
Function to convert a string to a number
What is int
The number of lines that will be printed
for number in [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]:
print("I have", number, "cookies. I'm going to eat one.")
What is 11
The index for the third element of a list
What is 2
What is printed:
x = 5
if x > 0:
print("Positive")
else:
print("Negative")
What is Positive
Which of the following correctly defines a function in Python?
A
function add(a, b) return a + b
B
def add(a, b): return a + b
C
def add = (a, b) => a + b
D
add(a, b) = def return a + b
What is B
The value that the last line print:
i = 1
while (i <= 3):
i = i + 1
print(i)
What is 4
fruits=[“apple”, “banana”, “grapes” , “oranges”]
print(fruits[3])What is oranges
What is the output of the following code snippet?
for i in range(5):
if i == 3:
continue
print(i)
A
0 1 2 3 4
B
0 1 2 4
C
0 1 2
D
0 1 2 3
What is B