Search Header Logo

2nd Quizz Python

Authored by Science Quiz

Information Technology (IT)

12th Grade

Used 2+ times

2nd Quizz Python
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a function in Python?

To execute code only once in a program

To create variables in Python

To define classes in Python

The purpose of a function in Python is to encapsulate code for reuse and organization.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you define a class in Python?

class ClassName() {}

class ClassName: pass()

class ClassName: pass

define ClassName as a function

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code: if 5 > 3: print('A') else: print('B')?

A

5

B

C

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a list in Python?

You create a list in Python using square brackets, e.g., my_list = [1, 2, 3].

You create a list in Python by calling the list() function, e.g., my_list = list(1, 2, 3).

You create a list in Python using curly braces, e.g., my_list = {1, 2, 3}.

You create a list in Python by using parentheses, e.g., my_list = (1, 2, 3).

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between a list and a tuple in Python?

Tuples are mutable; lists are immutable.

Lists are mutable; tuples are immutable.

Lists can contain only numbers; tuples can contain any data type.

Lists are faster than tuples in all cases.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access a value in a dictionary using a key?

Use dictionary_name[key] to modify the value.

Access the value with dictionary_name.key.

Use dictionary_name.get(key) to retrieve the value.

Use dictionary_name[key] to access the value.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the operation 10 % 3?

1

10

0

3

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?