Python If Statements

Quiz
•
Computers
•
University
•
Hard
Ruth Lock
Used 31+ times
FREE Resource
18 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct syntax for an if statement in Python?
if (condition) {code block}
if condition: code block
if condition then code block
if [condition] {code block}
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following operators is used to check if two values are not equal in Python?
!=
==
<=
>
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you write an if statement to check if `x` is greater than 10?
if x > 10:
if x is > 10:
if x >> 10:
if x gt 10:
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to write a nested if statement in Python?
if condition1: if condition2: code block
if condition1: then if condition2: code block
if condition1 & if condition2: code block
if condition1 > if condition2: code block
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which logical operator is used in Python to combine two boolean conditions and returns True if both conditions are true?
OR
AND
NOT
XOR
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code if `x = 5`? ```python if x > 2: print("Hello") elif x > 4: print("World") else: print("!") ```
Hello
World
!
Hello World
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which comparison operator is used to check if a value is less than or equal to another value in Python?
<
<=
==
!=
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
CSE 102 Exam 2 Practice

Quiz
•
University
15 questions
CN - ERROR CORRECTION & DETECTION

Quiz
•
University
21 questions
OCR A Level Computer Science (H446) - Component 1.2.2 - Application Generation

Quiz
•
11th Grade - University
20 questions
C++ Quiz

Quiz
•
University
15 questions
Code of Conduct & Privacy

Quiz
•
University
15 questions
Round 2 Debug-The-Code

Quiz
•
University
13 questions
JavaScript Variables

Quiz
•
3rd Grade - University
20 questions
Understanding Functions in Programming

Quiz
•
9th Grade - University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University