What is the type of x. where x = [1, 2, 3] in Python?
Lists
The type of loop commonly used to step or look through a sequence of items or repeat an action a set number of times.
for loop
The three-letter keyword used to define a new function in Python.
def
The keyword used to start a conditional block in Python.
if
The specific type of brackets used to define a list in Python
square brackets []
What is printed after executing the following code?
s = "python"
s.upper()
print(s)
"PYTHON"
The built-in function often used with for loops to generate a sequence of numbers.
range()
The built-in function used to display output or text to the screen.
print()
The comparison operator used to check if two values are equal to each other.
==
In the list fruits = ["apple", "banana", "cherry"], this item is located at index 0
The data type used for numbers that contain a decimal point, such as 3.14 or 0.5
float
The type of loop that continues executing as long as its conditional statement remains True
While
The keyword used inside a function to send a result back to where the function was called.
return
This logical operator returns True only if both conditions on either side of it are true.
and
The list method used to add a new item to the very end of an existing list.
.append
Any text enclosed within single or double quotes belongs to this data type.
string
What is the final value of nums after executing the following code?
nums = [1, 2, 3, 4]
for n in nums:
if n % 2 == 0:
nums.remove(n)
print(nums)
[1,3]
The names listed inside the parentheses of a function definition that receive values when the function is called.
parameters
How does Python evaluate the chained expression 1 < 5 < 3
False
What is the result of evaluating [10, 20, 30, 40, 50][::2]
[10,30,50]
Running type("100") in Python returns this data type.
string
What is printed upon executing the following loop with an else clause?
for i in range(2):
if i > 1:
break
else:
print("Done")
"Done"
What is outputted by the following code.
def sum_positives(numbers):
total = 0
for num in numbers:
if num > 0:
total += num
return total
print(sum_positives([1, -4, 7, 12]))
20
What does the following expression evaluate to?
a = [1, 2]
b = [1, 2]
print(a == b and not (a is b))
True
What is the output of the following code?
numbers = [10, 20, 30, 40, 50, 60, 70]
part2[1:2] = [99]
print(numbers)
[10, 99, 30, 40, 50, 60, 70]