
Understanding Python If Statements
Authored by Aram M
Computers
11th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of an `if` statement in Python?
To repeat a block of code multiple times
To execute a block of code only if a specified condition is true
To define a function
To import a module
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct syntax for an `if` statement in Python?
`if x = 5:`
`if (x == 5)`
`if x == 5:`
`if x := 5:`
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code snippet? ```python x = 10 if x > 5: print("Greater") else: print("Smaller") ```
Greater
Smaller
Error
None
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements is true about `if` statements in Python?
An `if` statement can only have one condition
An `if` statement must always be followed by an `else` statement
An `if` statement can be followed by multiple `elif` statements
An `if` statement cannot be nested within another `if` statement
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code: ```python x = 3 if x > 5: print("A") elif x == 3: print("B") else: print("C") ``` What will be printed?
A
B
C
Nothing
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? ```python x = 7 if x < 10: if x > 5: print("Yes") else: print("No") else: print("Maybe") ```
Yes
No
Maybe
Error
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a valid `if` statement in Python?
`if x = 10:`
`if x == 10:`
`if (x = 10):`
`if x := 10:`
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
12 questions
Tin học 2
Quiz
•
11th Grade
10 questions
Javascript & Client side scripting
Quiz
•
10th - 12th Grade
15 questions
ASK F1: Ulangkaji Akhir Tahun
Quiz
•
1st - 12th Grade
15 questions
Quiz Bahasa Pemrograman
Quiz
•
11th Grade
15 questions
History of Computers
Quiz
•
6th - 12th Grade
14 questions
Kiểu dữ liệu xâu kí tự - xử lí xâu kí tự
Quiz
•
9th - 12th Grade
15 questions
Lua Review Corona SDK with Notepad++
Quiz
•
10th - 12th Grade
10 questions
STM BTEC DIT 3- 5. Maintenance, set-up, performance p152
Quiz
•
9th - 11th Grade
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