Unit 2 Python

Quiz
•
Computers
•
University
•
Easy
Vishwanath Vishwanath
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
x = 5
if x > 3:
print("Hello")
elif x > 2:
print("Hi")
else:
print("Bye")
Hello
Bye
Hi
Error
Answer explanation
The first if condition is True, so Hello is printed, and the elif and else blocks are skipped.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct syntax for a for loop in Python?
for x in 10:
for x = 0; x < 10; x++:
for x range(10):
for x in range(10);
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements about while loops is correct?
A while loop runs only once
A while loop executes as long as the condition is True
A while loop runs a fixed number of times
A while loop cannot be used with else
Answer explanation
A while loop executes as long as the condition is True
Explanation: The while loop continues execution until the condition evaluates to False.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
for i in range(5):
if i == 3:
break
print(i)
0 1 2 3 4
0 1 2 3
0 1 2
1 2 3
Answer explanation
The break statement stops the loop when i == 3, so 3 and 4 are not printed.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
for i in range(5):
pass
print("Loop Completed")
Loop Completed
0 1 2 3 4 Loop Completed
Error
None
Answer explanation
The pass statement does nothing and is used as a placeholder.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of an if statement in Python?
To repeat a block of code
To check a condition and execute code if it's True
To stop the program
To create a function
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
x = 10
if x > 5:
print("Big number")
Big number
10
Error
No output
Create a free account and access millions of resources
Similar Resources on Wayground
12 questions
Python: Strings and Lists

Quiz
•
University
9 questions
Python Basics Quiz for KS3

Quiz
•
11th Grade - University
12 questions
Quiz3

Quiz
•
University
15 questions
Bootcamp Day 3 - Java Array

Quiz
•
University
10 questions
BEFORE UPS2 - D2T6

Quiz
•
University
10 questions
Python Basics Quiz

Quiz
•
7th Grade - University
10 questions
Web-II-Loop and Function

Quiz
•
University
11 questions
Control Structures - Selection in Python

Quiz
•
8th Grade - University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University