Python If Statements

Python If Statements

University

18 Qs

quiz-placeholder

Similar activities

PHP QUIZ

PHP QUIZ

University

14 Qs

Coding club Summit Online Quiz

Coding club Summit Online Quiz

University

15 Qs

PHP First Internal Practical Viva

PHP First Internal Practical Viva

University

20 Qs

PP-ASSESSMENT-1

PP-ASSESSMENT-1

University

20 Qs

PY LEVEL 1 QUIZ 2

PY LEVEL 1 QUIZ 2

8th Grade - University

15 Qs

OCR A Level Computer Science (H446) - Component 1.1.2 - Types of Processor

OCR A Level Computer Science (H446) - Component 1.1.2 - Types of Processor

11th Grade - University

19 Qs

Python Basics

Python Basics

University

15 Qs

Python exam preparation

Python exam preparation

University

18 Qs

Python If Statements

Python If Statements

Assessment

Quiz

Computers

University

Hard

Created by

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

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?