Mastering Python Loops, Lists and Strings

Mastering Python Loops, Lists and Strings

11th Grade

30 Qs

quiz-placeholder

Similar activities

ทดสอบภาษาไพทอนเบื้องต้น

ทดสอบภาษาไพทอนเบื้องต้น

10th - 12th Grade

30 Qs

XI Computer Science - 3

XI Computer Science - 3

11th Grade

28 Qs

TECH IQ CLASH

TECH IQ CLASH

9th - 12th Grade

25 Qs

Algorithms - python (GCSE)

Algorithms - python (GCSE)

10th - 12th Grade

25 Qs

Their Python Exam

Their Python Exam

9th Grade - Professional Development

31 Qs

Python Review

Python Review

8th - 12th Grade

35 Qs

Python Basics Str's & Stmts 126

Python Basics Str's & Stmts 126

9th - 12th Grade

26 Qs

Mastering Python Loops, Lists and Strings

Mastering Python Loops, Lists and Strings

Assessment

Quiz

Computers

11th Grade

Hard

Created by

Harmeet Kaur

FREE Resource

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the syntax for a for loop in Python?

foreach variable in sequence:

for each variable in sequence:

for (variable; condition; increment)

for variable in sequence:

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How do you create a while loop that runs until a variable reaches 10?

while (variable = 10) { variable++; }

while (variable < 10) { variable++; }

while (variable != 10) { variable++; }

while (variable > 10) { variable--; }

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What method would you use to convert a string to lowercase in Python?

lowercase()

convertToLower()

.lower()

.toLowerCase()

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How can you create a list of squares of numbers from 1 to 10 using list comprehension?

[x^2 for x in range(1, 10)]

[x**2 for x in range(1, 11)]

[x*2 for x in range(1, 11)]

[x**3 for x in range(1, 11)]

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

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

0 1 2 3 4

3.5

-1

5

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Explain how nested loops work with an example.

For example, in a 2D array, an outer loop can iterate through rows, while an inner loop iterates through columns: for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { process(array[i][j]); } }

An outer loop cannot access the inner loop's variables.

Nested loops can only be used with single-dimensional arrays.

Nested loops are not efficient for processing data.

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What string method would you use to find the length of a string?

length()

count()

len()

size()

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?