
S4: RECAP UNTIL TESTING
Quiz
•
Computers
•
11th Grade
•
Practice Problem
•
Medium
Kieran Kyle
Used 1+ times
FREE Resource
Enhance your content in a minute
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
x = 10
if x > 5:
print("Greater")
else:
print("Smaller")
Greater
Smaller
Error
No Output
Answer explanation
The if statement checks if x is greater than 5. Since x is 10, the condition is True, and "Greater" is printed.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the final value of sum after this code is executed?
num = 0
for i in range(5):
num = num + i
print(num)
5
10
15
20
Answer explanation
The loop iterates over a range of 5 numbers from 0 to 4. The sum of these numbers (0+1+2+3+4) is 10
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the list my_list = ["apple", "banana", "cherry"]
What does print(len(my_list)) return?
3
6
15
Error
Answer explanation
The len() function returns the number of items in an object. Since my_list contains three items, the result is 3.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be printed by the following code snippet?
fruits = ["apple", "banana", "cherry"]
print(fruits[1])
apple
banana
cherry
IndexError
Answer explanation
Arrays in Python are zero-indexed, so fruits[1] refers to the second element in the list, which is "banana".
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code do?
user_input = 0
while user_input < 1 or user_input > 10:
user_input = int(input("Enter a number between 1 and 10: "))
Repeats until a number less than 1 is entered.
Repeats until a number greater than 10 is entered.
Repeats until a number between 1 and 10 is entered.
Causes an infinite loop.
Answer explanation
The code keeps asking for input until the user enters a number within the range 1-10 (inclusive).
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How does the following code snippet calculate a running total?
numbers = [1, 2, 3, 4, 5]
total = 0
for index in numbers:
total = total + index
Adds the index of each element to total.
Adds the value of each element to total.
Multiplies the value of each element with total.
Subtracts the value of each element from total.
Answer explanation
The code iterates through the list numbers and adds each to the total variable, accumulating the sum of the list elements.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What kind of error will occur when the following code is executed?
for i in range(10)
print(i)
Syntax
Logic
Execution
Extreme
Answer explanation
The code is missing a colon : at the end of the for loop declaration, which is required in Python to indicate the start of the loop's body. This will result in a syntax error when the code is run.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
14 questions
Bài 29. Nhận biết lỗi chương trình
Quiz
•
9th - 12th Grade
8 questions
Overview of IT
Quiz
•
6th Grade - University
10 questions
Avaliação 1T - JavaScript
Quiz
•
9th - 12th Grade
15 questions
4.6.4 Logic Gates
Quiz
•
10th Grade - Professi...
12 questions
Wee Word Intro
Quiz
•
7th - 12th Grade
14 questions
K10 - WHILE
Quiz
•
11th Grade
10 questions
USING HAND TOOLS
Quiz
•
11th Grade
13 questions
Five Nights At Freddy's: Security Breach Quiz
Quiz
•
KG - Professional Dev...
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
