placeholder image to represent content

Python 06: Loops

Quiz by Jonathan Saurine

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
20 questions
Show answers
  • Q1
    Which of the following is used to repeat a block of code a specified number of times in Python?
    try/except block
    while loop
    for loop
    if statement
    120s
  • Q2
    What is the correct way to access the last element of a list in Python?
    list_name[0]
    list_name[-0]
    list_name[1]
    list_name[-1]
    120s
  • Q3
    Which of the following is used to loop through each element in a list in Python?
    try/except block
    for loop
    while loop
    if statement
    120s
  • Q4
    Which of the following Python data structures is ordered and changeable?
    dictionary
    list
    set
    tuple
    120s
  • Q5
    Which of the following statements correctly defines a Python list?
    A list is a collection of items that are ordered and changeable.
    A list is an unordered collection of items in Python.
    A list is a key-value pair data structure in Python.
    A list is an immutable data structure in Python.
    120s
  • Q6
    Which of the following Python loops is used to repeat a block of code as long as a certain condition is true?
    For loop
    While loop
    If statement
    Try/Except block
    120s
  • Q7
    Which of the following is the correct way to check if an element is present in a Python list?
    element in list_name
    element not in list_name
    list_name.includes(element)
    list_name.contains(element)
    120s
  • Q8
    Which of the following is the correct way to add an element to the end of a Python list?
    list_name.add(element)
    list_name.extend(element)
    list_name.insert(element)
    list_name.append(element)
    120s
  • Q9
    Which of the following is the correct syntax to create an empty list in Python?
    list_name = ()
    list_name = ''
    list_name = {}
    list_name = []
    120s
  • Q10
    What is the output of the following code?<p><pre><code>numbers = [1, 2, 3, 4, 5]<br>for num in numbers: <br>   print(num)</code></pre></p>
    2345
    1
    54321
    12345
    120s
  • Q11

    What is the output of the following Python code?<p><pre><code>numbers = [1, 2, 3, 4, 5]<br>sum = 0<br>for num in numbers: <br>   sum += num<br>print(sum)</pre></code></p>

    10
    14
    5
    15
    120s
  • Q12
    Which of the following is a correct example of a while loop in Python?
    while x < 10:
    for x in range(10):
    do while x < 10:
    if x < 10:
    120s
  • Q13

    What is the output of the following Python code?<p><pre><code>fruits = ["apple" "banana", "cherry"]<br>for fruit in fruits:<br>   print(fruit)</code></pre></p>

    apple
    fruits
    banana
    cherry
    012
    applebananacherry
    120s
  • Q14
    What is the output of the following Python code?<p><pre><code>numbers = [1, 2, 3, 4, 5]<br>for num in numbers:<br>    if num % 2 == 0:<br>     continue<br>print(num)</code></pre></p>
    135
    24
    12345
    245
    13
    120s
  • Q15
    What is the output of the following Python code?<p><pre><code>for i in range(1, 6):<br>   print(i)</code></pre></p>
    135
    12345
    246
    1234
    123456
    120s

Teachers give this quiz to your class