What will be the output of the following code? def func(x, y=[]): y.append(x) return y print(func(1)) print(func(2))

Python Programming Quiz

Quiz
•
Information Technology (IT)
•
2nd Grade
•
Hard
Thủy Nguyễn
Used 1+ times
FREE Resource
21 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
a) [1], [2]
b) [1], [1, 2]
c) [1, 2], [1, 2]
d) [2], [2, 2]
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the `itertools` module provide?
a) A collection of tools for handling iterators
b) A collection of tools for working with images
c) A collection of tools for working with files
d) A collection of tools for working with databases
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements about Python decorators is true?
a) Decorators can only be applied to functions
b) Decorators can be used to modify classes and functions
c) Decorators are used to create new functions
d) Decorators cannot accept arguments
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following methods is used to read all the lines of a file into a list in Python?
a) `readlines()`
b) `read()`
c) `readline()`
d) `readall()`
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code? class MyClass: def __init__(self, value=0): self.value = value obj1 = MyClass(5) obj2 = MyClass() print(obj1.value, obj2.value)
a) 5 0
b) 0 5
c) 5 5
d) 0 0
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the `zip()` function do in Python?
a) Combines elements from two or more iterables into tuples
b) Compresses a string
c) Encrypts data
d) None of the above
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code? x = [1, 2, 3, 4] y = [5, 6, 7, 8] z = [a + b for a, b in zip(x, y)] print(z)
a) [1, 2, 3, 4, 5, 6, 7, 8]
b) [6, 8, 10, 12]
c) [5, 7, 9, 11]
d) [2, 4, 6, 8]
Create a free account and access millions of resources
Similar Resources on Quizizz
21 questions
Repaso Tema 1

Quiz
•
1st Grade - University
20 questions
Ôn tập Công nghệ 4 HKI

Quiz
•
1st - 5th Grade
21 questions
Circuitos e Programação Divertida

Quiz
•
2nd Grade
16 questions
Découverte de Scratch

Quiz
•
2nd Grade
20 questions
EXAMEN PHOTOSHOP

Quiz
•
1st - 5th Grade
20 questions
Logica_Diagnostica

Quiz
•
2nd Grade
20 questions
2A ADMIN EXAMEN 2DO PARCIAL

Quiz
•
2nd Grade
18 questions
Introdução a Lógica de Programação 1

Quiz
•
2nd Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Information Technology (IT)
10 questions
American Flag

Quiz
•
1st - 2nd Grade
10 questions
Identifying equations

Quiz
•
KG - University
10 questions
2nd Grade math review

Quiz
•
2nd Grade
26 questions
Place Value Review

Quiz
•
2nd Grade
25 questions
2.4A Add Subtract within 20 quickly: set 3

Quiz
•
1st - 3rd Grade
12 questions
Summer Trivia

Quiz
•
1st - 5th Grade
15 questions
Music 2016

Quiz
•
KG - 12th Grade
44 questions
logos

Quiz
•
KG - University