Search Header Logo

Python Class Quiz

Authored by Herr Blank

Computers

11th Grade

DOK Level 2: Skill/Concept covered

Used 1+ times

Python Class Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

14 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax to create an instance of a class named `Vehicle`?

`Vehicle newCar = new Vehicle();`

`newCar = Vehicle()`

`newCar = Vehicle`

`newCar = Vehicle()`

Tags

DOK Level 2: Skill/Concept

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements is true about attributes in Python classes?

Attributes are always public and can be accessed using any instance.

Attributes can be defined within methods and accessed outside the class.

Attributes are variables that belong to the class.

Attributes cannot be initialized in the constructor.

Tags

DOK Level 2: Skill/Concept

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the `__init__` method do in a Python class?

It is called to initialize the class's state.

It declares the class to other modules.

It is called automatically whenever a new object is created.

Both A and C are correct.

Tags

DOK Level 2: Skill/Concept

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Python, how do you define a constructor for initializing the attributes of a class?

`def __init__(self):`

`def __constructor__(self):`

`def Vehicle(self):`

`def __init__():`

Tags

DOK Level 2: Skill/Concept

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of inheritance in Python classes?

To allow classes to inherit methods and attributes from other modules.

To permit the creation of new classes that reuse, extend, and modify the behavior defined in other classes.

To prevent duplication of code across similar classes.

All of the above are correct.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you call a method from a parent class in a child class method in Python?

`super().methodName()`

`parent.methodName()`

`self.methodName()`

`methodName()`

Tags

DOK Level 2: Skill/Concept

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to add an attribute `color` to a class `Car` and initialize it?

```python class Car: def __init__(self, color): self.color = color ```

```python class Car: color = '' def __init__(self, color): color = self.color ```

```python class Car: def __init__(self, color): color = color ```

```python class Car: def __init__(self): self.color = 'color' ```

Tags

DOK Level 2: Skill/Concept

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?