Search Header Logo

Python Quiz 1

Authored by 254009 BALASUBRAMANIAN

others

Python Quiz 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the advantage of using generators compared to lists?

Generators are faster for large datasets.
Generators can be modified after creation.
Generators use less memory.
Generators use more memory.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the try-except block do in Python?

Defines a loop structure.
Handles potential errors during code execution
Checks for specific variable values.
Creates a conditional statement.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between a module and a package in Python?

Modules contain functions and variables, packages group related modules.
Packages are executable code, modules are not.
Modules are for internal use, packages are for external use.
There's no difference.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you open a file for writing in Python?

open("filename.txt", "r")
open("filename.txt", "w")
open("filename.txt", "a") (append mode)
open("filename.txt") (default read mode)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What are the pillars of Object-Oriented Programming (OOP)?

Inheritance, Encapsulation, Polymorphism
Functions, Variables, Loops
Modules, Packages, Libraries
Lists, Tuples, Dictionaries

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? import array as arr MY_array=arr.array('i',[1,2,3,4,5]) MY-array[::-1]

[5, 4, 3, 2, 1]
array(‘i’, [5, 4, 3, 2, 1])
array([5, 4, 3, 2, 1])
array(‘i’, [1,2,3,4,5])

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a decorator in Python?

To modify the behavior of a function without changing its code.
To define a new data type.
To improve code readability.
To optimize code performance.

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

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?