
Understanding Python Conditionals

Quiz
•
Computers
•
11th Grade
•
Medium
Kavita Bhagat
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: if x > 10: print('Greater') elif x < 10: print('Lesser') else: print('Equal')?
Greater
Undefined
Lesser
Equal
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Write a Python program using if-elif-else to check if a number is positive, negative, or zero.
number = int(input('Enter a number: ')) if number < 0: print('Zero') elif number > 0: print('Negative') else: print('Positive')
number = float(input('Enter a number: ')) if number >= 0: print('Zero') else: print('Positive')
number = float(input('Enter a number: ')) if number > 0: print('Positive') elif number < 0: print('Negative') else: print('Zero')
number = input('Enter a number: ') if number == 0: print('Positive') else: print('Negative')
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How does the if statement differ from the if-elif-else statement in Python?
The 'if' statement is used for defining functions.
The 'if' statement checks one condition, while 'if-elif-else' checks multiple conditions in sequence.
The 'if-elif-else' statement is used for loops only.
The 'if' statement can check multiple conditions at once.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be printed if x = 5 in the following code: if x > 10: print('High') elif x == 5: print('Medium') else: print('Low')?
Very High
Low
High
Medium
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Create a conditional statement that checks if a student has passed based on their marks (pass mark is 40).
if (marks < 40) { return 'Passed'; } else { return 'Failed'; }
if (marks == 40) { return 'Failed'; } else { return 'Passed'; }
if (marks > 40) { return 'Failed'; } else { return 'Passed'; }
if (marks >= 40) { return 'Passed'; } else { return 'Failed'; }
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the use of the else statement in an if-elif-else structure.
The 'else' statement provides a default action when all other conditions fail.
The 'else' statement can only be used with a single if condition.
The 'else' statement is used to replace the if statement entirely.
The 'else' statement is only executed if the first condition is true.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code: if a == b: print('Equal') elif a > b: print('A is greater') else: print('B is greater')?
A is always greater
B is always greater
Equal regardless of values
Depends on the values of a and b
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
quiz o python

Quiz
•
9th - 12th Grade
10 questions
2DO BACHILLERATO - SEGUNDO PARCIAL - PROGRAMACION

Quiz
•
11th Grade
11 questions
If Else Check In

Quiz
•
11th Grade
14 questions
Cyber Security - Social Engineering

Quiz
•
10th - 11th Grade
5 questions
Topic 3.4 Video 1

Quiz
•
11th Grade
15 questions
Java Script Quiz

Quiz
•
9th - 12th Grade
14 questions
PYTHON DICTIONARIES

Quiz
•
11th Grade
7 questions
الجملة الشرطية الكاملة if-else

Quiz
•
11th Grade
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