
Python programming, For loops, while loops, If statements and variables
Quiz by Fred Barber
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
9 questions
Show answers
- Q1What is the output of the following Python code?x = 5while x > 0: print(x) x = x - 1123455432111111555555432130s
- Q2What is the output of the following Python code snippet?for i in range(1, 6): if i % 2 == 0: print(i) else: continue2412345213542430s
- Q3What is the purpose of the 'if' statement in Python?To conditionally execute code based on a given conditionTo define a named storage location for a valueTo iterate over a sequence of elementsTo repeat a block of code a specified number of times30s
- Q4What is the output of the following Python code?x = 0while x < 10: print(x) x += 2024680246813579012345678910108642030s
- Q5Which of the following is a correct Python variable name?variable-mymyVariable1_variableVariable1my_variable30s
- Q6What is the output of the following Python code?x = 10while x >= 0: print(x) x -= 112345678910109876543210012345678910109876543210010203040506070809010030s
- Q7What is the output of the following Python code?x = 5for i in range(x): print(i)123455555501234012344321030s
- Q8What is the correct syntax to check if a variable 'x' is equal to 10 in Python?if x != 10:if x == 10:if x =! 10:if x === 10:if x = 10:30s
- Q9What is the purpose of a while loop in Python?To repeatedly execute a block of code as long as a condition is TrueTo iterate over a sequence of elementsTo conditionally execute code based on a given conditionTo define a named storage location for a value30s