Python: Built-In Functions and Upto Tuple

Python: Built-In Functions and Upto Tuple

University

50 Qs

quiz-placeholder

Similar activities

Final Quiz Jarkom Lanjut

Final Quiz Jarkom Lanjut

University

52 Qs

Technical Training Test for III BTech - VCE - CSE

Technical Training Test for III BTech - VCE - CSE

University

45 Qs

Module 10

Module 10

University

48 Qs

Malware

Malware

12th Grade - Professional Development

46 Qs

cisco Introduction to Networks

cisco Introduction to Networks

1st Grade - University

50 Qs

MidTerm Exam - CS122 - 12024

MidTerm Exam - CS122 - 12024

University

50 Qs

IT Fundamentals Test Part 1

IT Fundamentals Test Part 1

KG - University

49 Qs

Máy tính - Người bạn mới của em

Máy tính - Người bạn mới của em

2nd Grade - University

50 Qs

Python: Built-In Functions and Upto Tuple

Python: Built-In Functions and Upto Tuple

Assessment

Quiz

Computers

University

Hard

Created by

Mayank Saxena

Used 9+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

50 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What will print([1, 2, 3] + [4, 5]) output?

[1, 2, 3, 4, 5]

[5, 4, 3, 2, 1]

Error

[1, 2, 3, [4, 5]]

Answer explanation

The + operator concatenates two lists.

2.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

Which of the following will create a shallow copy of a list a?


b = a[:]


b = a.copy()


b = a[:]
and
b = a.copy()
both options correct


None of the above

Answer explanation

Both slicing and copy() create a shallow copy of the list.

3.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What will print(len([[1, 2], [3, 4]])) return?

2

4

8

Error

Answer explanation

The len() function returns the number of top-level elements, which is 2.

4.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

Which of the following will raise an error for tuple a?


a = (1, 2)


a[0] = 3


len((1, 2, 3))


(1, 2) + (3,)

Answer explanation

Tuples are immutable; modifying an element is not allowed.

5.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

What is the output of print((1, 2) * 2)?


(1, 2, 1, 2)


(1, 2, 2)


Error


[1, 2, 1, 2]

Answer explanation

The * operator repeats the tuple.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output?
for i in range(3):
 ↳ for j in range(2):
 ↳ print(i * j, end=" ")

Note:  ↳ indicating that the statement is the part of its above block

0 0 0 1 0 2


0 0 0 0 0 1


0 0 0 1


0 0 0 0 1 2

Answer explanation

The nested loops compute i * j for all combinations of i and j.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Error Correction: Fix the code to break the loop:
i = 0

while True:

↳print(i)

↳if i == 5:

↳break

Note:  ↳ indicating that the statement is the part of its above block

Add i += 1 before break

Use for instead of while

Add i += 1 after print(i)


Replace break with continue

Answer explanation

Increment i after print(i) to avoid an infinite loop.

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

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

Already have an account?