
Python 06: Loops
Quiz by Jonathan Saurine
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
20 questions
Show answers
- Q1Which of the following is used to repeat a block of code a specified number of times in Python?try/except blockwhile loopfor loopif statement120s
- Q2What 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
- Q3Which of the following is used to loop through each element in a list in Python?try/except blockfor loopwhile loopif statement120s
- Q4Which of the following Python data structures is ordered and changeable?dictionarylistsettuple120s
- Q5Which 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
- Q6Which of the following Python loops is used to repeat a block of code as long as a certain condition is true?For loopWhile loopIf statementTry/Except block120s
- Q7Which of the following is the correct way to check if an element is present in a Python list?element in list_nameelement not in list_namelist_name.includes(element)list_name.contains(element)120s
- Q8Which 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
- Q9Which of the following is the correct syntax to create an empty list in Python?list_name = ()list_name = ''list_name = {}list_name = []120s
- Q10What 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>234515432112345120s
- 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>
1014515120s - Q12Which 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>
applefruitsbananacherry012applebananacherry120s - Q14What 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>135241234524513120s
- Q15What is the output of the following Python code?<p><pre><code>for i in range(1, 6):<br> print(i)</code></pre></p>135123452461234123456120s