Understanding Python Conditionals

Understanding Python Conditionals

11th Grade

10 Qs

quiz-placeholder

Similar activities

Управление циклом: else . 8 класс

Управление циклом: else . 8 класс

8th Grade - University

10 Qs

P5.js Variables and Conditional Statements

P5.js Variables and Conditional Statements

9th - 12th Grade

15 Qs

Class-XI_IP_Python

Class-XI_IP_Python

11th Grade

10 Qs

Условный оператор_лекция6

Условный оператор_лекция6

11th Grade

8 Qs

Python Programming

Python Programming

5th Grade - University

15 Qs

From Scratch to Python Quiz Unit 1 ,1.7-1.9

From Scratch to Python Quiz Unit 1 ,1.7-1.9

KG - 12th Grade

7 Qs

Python Test

Python Test

9th - 12th Grade

13 Qs

Python бағдарламалау тілі

Python бағдарламалау тілі

11th Grade

15 Qs

Understanding Python Conditionals

Understanding Python Conditionals

Assessment

Quiz

Computers

11th Grade

Medium

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?