Search Header Logo

python

Authored by Auzoom four

Education

Professional Development

Used 1+ times

python
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the time complexity of accessing an element by index in a list in Python?



a) O(1)

b) O(n)

c) O(log n)

d) O(n^2)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output?

lst = [1, 2, 3, 4]

lst[1:3] = [9, 8]

print(lst)

[1, 9, 8, 4]

[1, 2, 9, 8, 4]

[1, 9, 8]

Error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

lst = [1, 2, 3]

lst.insert(1, 10)

print(lst)

a) [1, 10, 2, 3]

b) [10, 1, 2, 3]

c) [1, 2, 3, 10]

d) Error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How would you remove all elements from a list lst?

a) lst.clear()

b) lst.remove()

c) lst.delete()

d) lst.reset()

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output?

lst = [5, 10, 15, 20]

lst[1:3] = [8, 12]

print(lst)

a) [5, 8, 12, 20]

b) [5, 8, 12, 15, 20]

c) [5, 8, 12]

d) [5, 8, 12, 15, 20]

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

my_set = {1, 2, 3, 4, 5}

my_set.add(5)

print(my_set)

a) {1, 2, 3, 4, 5}

b) {5, 1, 2, 3, 4}

c) {1, 2, 3, 4, 5, 5}

d) Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the following operation?

a = {1, 2, 3}

b = {3, 4, 5}

result = a & b

print(result)

a) {1, 2}

b) {3}

c) {3, 4, 5}

d) {1, 2, 3, 4, 5}

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?