python day 3

python day 3

University

15 Qs

quiz-placeholder

Similar activities

Quiz_C++ language

Quiz_C++ language

University

20 Qs

12042022

12042022

University

10 Qs

Programming Fundamentals

Programming Fundamentals

KG - University

20 Qs

Python workshop day2

Python workshop day2

University

20 Qs

Python Programming

Python Programming

3rd Grade - University

17 Qs

Java Arrays

Java Arrays

5th Grade - University

10 Qs

Day - 3

Day - 3

University

15 Qs

MIDTERM EXAM

MIDTERM EXAM

University

18 Qs

python day 3

python day 3

Assessment

Quiz

Other

University

Medium

Created by

NAVIN B

Used 2+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of an if statement in programming?

What is the purpose of an if statement in programming?

To execute a block of code only if a specified condition is true 

To exit a loop immediately 

To define a function

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When is the else block executed in an if-else statement?

Always 

Only when the if condition is true 

Only when the if condition is false 

Only when there is an error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the elif keyword stand for in Python?

Else if 

Else loop 

Else iteration 

Else function

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is true about nested if statements?

They allow an if statement to be inside another if statement 

They cannot contain elif statements 

They must end with an else statement 

They can only be two levels deep

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why is a dictionary often used to simulate a switch statement in Python?

Because Python does not have a built-in switch statement 

Because dictionaries are faster than if-else statements 

Because dictionaries are easier to read 

Because dictionaries are the only way to handle multiple conditions

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary purpose of a for loop?

To execute a block of code while a condition is true 

To execute a block of code a specific number of times 

To execute a block of code only if a condition is false 

To define a function

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When does a while loop terminate?

When a condition becomes true 

When a condition becomes false 

After a fixed number of iterations 

When there is a syntax error

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?