Python Quiz

Quiz
•
Computers
•
University
•
Hard
Mayank Saxena
Used 13+ times
FREE Resource
40 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
10 sec • 1 pt
Which method is used to get the value associated with a key in a dictionary?
value()
get()
key()
items()
Answer explanation
The get() method retrieves the value for a given key.
7.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What will print(len({1: "a", 2: "b"})) return?
1
2
3
4
Answer explanation
The len() function counts the number of key-value pairs.
Create a free account and access millions of resources
Similar Resources on Wayground
35 questions
Database

Quiz
•
KG - University
40 questions
INFORMATIKA KECANTIKAN

Quiz
•
1st Grade - University
37 questions
Ujian Administrasi Infrastruktur Jaringan

Quiz
•
12th Grade - University
45 questions
Microsoft Excels: Formulas and Functions

Quiz
•
12th Grade - University
40 questions
Repaso Python

Quiz
•
11th Grade - University
38 questions
Secure Scripting: Exam 1 Review: Modules 1 - 4

Quiz
•
University
40 questions
Quiz Pemrograman Python

Quiz
•
University
40 questions
Trivia(Explore in depth)

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University