Mastering Python Basics

Mastering Python Basics

12th Grade

20 Qs

quiz-placeholder

Similar activities

TN +2 -LESSON1 FUNCTIONS

TN +2 -LESSON1 FUNCTIONS

12th Grade

20 Qs

8.12 C++ Test on Classes

8.12 C++ Test on Classes

9th - 12th Grade

15 Qs

Unit 2 Programming Quiz

Unit 2 Programming Quiz

9th - 12th Grade

20 Qs

C++ Functions Review Quiz

C++ Functions Review Quiz

9th Grade - University

25 Qs

AP CSP CPT Practice Quiz

AP CSP CPT Practice Quiz

8th - 12th Grade

17 Qs

Functions With Parameters and Returns

Functions With Parameters and Returns

9th - 12th Grade

20 Qs

Intro to CS Final Exam Review - Day 2

Intro to CS Final Exam Review - Day 2

9th - 12th Grade

15 Qs

JS #4 Functions That Return Information

JS #4 Functions That Return Information

12th Grade - University

20 Qs

Mastering Python Basics

Mastering Python Basics

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Sakthivel Duraisamy

Used 5+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax for a for loop in Python?

for variable in sequence[]

for (variable : sequence)

for variable in (sequence)

for variable in sequence:

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you iterate over a list using a for loop?

foreach item in my_list:

for each item in my_list:

for item in list my_list:

for item in my_list:

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code: for i in range(5): print(i)?

0 1 2 3 4

-1

10

5

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create an infinite while loop in Python?

while True:

while False:

while 1:

while x < 10:

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between a while loop and a for loop?

A while loop is always faster than a for loop.

A for loop can only iterate over arrays, while a while loop can iterate over any data type.

A while loop requires a counter variable, while a for loop does not.

A while loop checks the condition before each iteration, while a for loop is used for a specific number of iterations with initialization and increment.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you break out of a while loop?

Use the 'continue' statement.

Remove the loop condition.

Use the 'break' statement.

Add a return statement.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the continue statement in a loop?

The continue statement restarts the loop from the beginning.

The continue statement ends the loop immediately.

The continue statement pauses the loop for a specified time.

The continue statement skips the current iteration of a loop.

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?