Data Types
Loops
Functions
If Statements
Lists
100

What is the type of x. where x = [1, 2, 3] in Python?

Lists

100

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

100

The three-letter keyword used to define a new function in Python.

def

100

The keyword used to start a conditional block in Python.

if

100

The specific type of brackets used to define a list in Python

square brackets []

200

What is printed after executing the following code?

s = "python"
s.upper()
print(s)

"PYTHON"

200

The built-in function often used with for loops to generate a sequence of numbers.

range()

200

The built-in function used to display output or text to the screen.

print()

200

The comparison operator used to check if two values are equal to each other.

==

200

In the list fruits = ["apple", "banana", "cherry"], this item is located at index 0

apple
300

The data type used for numbers that contain a decimal point, such as 3.14 or 0.5

float

300

The type of loop that continues executing as long as its conditional statement remains True

While

300

The keyword used inside a function to send a result back to where the function was called.

return

300

This logical operator returns True only if both conditions on either side of it are true.

and

300

The list method used to add a new item to the very end of an existing list.

.append

400

Any text enclosed within single or double quotes belongs to this data type.

string

400

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]

400

The names listed inside the parentheses of a function definition that receive values when the function is called.

parameters

400

How does Python evaluate the chained expression 1 < 5 < 3  

False

400

What is the result of evaluating [10, 20, 30, 40, 50][::2]

[10,30,50]

500

Running type("100") in Python returns this data type.

string

500

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"

500

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

500

What does the following expression evaluate to?

a = [1, 2] 

b = [1, 2] 

print(a == b and not (a is b))

True

500

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]