Python Lists

Python Lists

University

15 Qs

quiz-placeholder

Similar activities

Python функциялары  7 сынып

Python функциялары 7 сынып

12th Grade - University

15 Qs

Q4 - Comp Vision (FUNCTION)

Q4 - Comp Vision (FUNCTION)

University

10 Qs

Python_programming_quiz

Python_programming_quiz

University

10 Qs

1212 Midterm Review

1212 Midterm Review

University

20 Qs

PAP Module-3 Part3

PAP Module-3 Part3

University

15 Qs

CETA'S Quizzard

CETA'S Quizzard

University

20 Qs

GirlsWhoML Workshop 0

GirlsWhoML Workshop 0

University

20 Qs

SCRIPTING PROGRAMMING WITH PYTHON

SCRIPTING PROGRAMMING WITH PYTHON

University

15 Qs

Python Lists

Python Lists

Assessment

Quiz

Computers

University

Medium

Created by

Ilyas Ustun

Used 2+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the simplest way to create a new list in Python?

Using angle brackets <>

Using square brackets []

Using curly braces {}

Using parentheses ()

Answer explanation

The simplest way to create a new list in Python is by using square brackets []. This syntax allows you to define a list directly, while angle brackets, curly braces, and parentheses are used for other data types like sets and tuples.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the expression 'len([])'?

1

0

None

Error

Answer explanation

The expression 'len([])' calculates the length of an empty list. Since there are no elements in the list, the length is 0. Therefore, the correct answer is 0.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which operator is used to concatenate two lists in Python?

+

*

|

&

Answer explanation

In Python, the '+' operator is used to concatenate two lists, combining their elements into a new list. The other operators listed do not perform list concatenation.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the 'append' method do in a list?

Removes an element from the list

Reverses the order of the list

Sorts the list in ascending order

Adds a new element to the end of the list

Answer explanation

The 'append' method in a list adds a new element to the end of the list. This is different from removing elements, reversing order, or sorting, making 'adds a new element to the end of the list' the correct choice.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you check if two variables refer to the same object in Python?

Using the 'in' operator

Using the 'is' operator

Using the '==' operator

Using the '!=' operator

Answer explanation

To check if two variables refer to the same object in Python, use the 'is' operator. This operator compares the identities of the objects, while '==' checks for value equality. Thus, 'is' is the correct choice.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the term for a list that is an element of another list?

Sublist

Nested list

Inner list

Child list

Answer explanation

A 'nested list' refers to a list that contains other lists as its elements. This term accurately describes the relationship where one list is an element of another, distinguishing it from other options like 'sublist' or 'inner list'.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of 'sorted([3, 1, 2])'?

[3, 2, 1]

[2, 1, 3]

[1, 2, 3]

[3, 1, 2]

Answer explanation

The 'sorted()' function returns a new list containing all items from the iterable in ascending order. For the input [3, 1, 2], the sorted output is [1, 2, 3], making it the correct choice.

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?