Exploring Python Lists and Tuples

Exploring Python Lists and Tuples

University

10 Qs

quiz-placeholder

Similar activities

Séance 8

Séance 8

University

13 Qs

Fundamentals of Python Programming

Fundamentals of Python Programming

University

10 Qs

Увлекательный мир Python

Увлекательный мир Python

6th Grade - University

9 Qs

Club Coding Quiz - BCA

Club Coding Quiz - BCA

University

10 Qs

Компьютерные модели

Компьютерные модели

11th Grade - University

15 Qs

Understanding Python Basics

Understanding Python Basics

University

12 Qs

Python for loop/lists

Python for loop/lists

9th Grade - University

15 Qs

Coding With Python- Introductory Quiz

Coding With Python- Introductory Quiz

University

13 Qs

Exploring Python Lists and Tuples

Exploring Python Lists and Tuples

Assessment

Quiz

Information Technology (IT)

University

Hard

Created by

Ruby Chen

Used 1+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following operations can be performed on a Python list but not on a tuple?

Accessing elements by index

Appending elements

Iterating over elements

Checking membership with `in`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet? ```python my_tuple = (1, 2, 3) my_tuple[1] = 4 ```

`(1, 4, 3)`

`(1, 2, 3)`

`TypeError`

`(4, 2, 3)`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct list comprehension to create a list of squares of numbers from 0 to 4?

`[x^2 for x in range(5)]`

`[x**2 for x in range(5)]`

`[x*2 for x in range(5)]`

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

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the following tuple unpacking? ```python a, b, c = (4, 5, 6) ```

`a = 4, b = 5, c = 6`

`a = 6, b = 5, c = 4`

`a = 5, b = 6, c = 4`

`a = 4, b = 6, c = 5`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following slicing operation on a list? ```python my_list = [10, 20, 30, 40, 50] print(my_list[1:4]) ```

`[10, 20, 30]`

`[20, 30, 40]`

`[30, 40, 50]`

`[20, 30, 40, 50]`

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the tuple slicing operation below. What will be the output? ```python my_tuple = (10, 20, 30, 40, 50) print(my_tuple[2:]) ```

`(10, 20, 30)`

`(30, 40, 50)`

`(20, 30, 40)`

`(40, 50)`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements about tuples is true?

Tuples are mutable.

Tuples can contain duplicate elements.

Tuples do not support indexing.

Tuples can be resized.

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?