Search Header Logo

Chapter 9 review

Authored by Adrian Ortiga

Science

9th - 12th Grade

25 Questions

Used 2+ times

Chapter 9 review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is my dog in the given code snippet?

my_dog = Dog('blacky', 2)

A method that initializes the dog object.

A variable representing the name of the dog.

An instance of the Dog class.

An attribute storing the dog's age.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access classes when importing an entire module?

Use the syntax module_name.class_name

Use the syntax class_name.module_name

You cannot import and entire module.

Use the syntax module_name -> class_name

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a method in Python?

A built-in Python keyword used to define classes.

A data type that stores a collection of values.

A function that's part of a class.

A statement used to control the flow of execution in a program.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens if you only use one underscore before and after the method init()?

The method won't be called automatically when you use your class.

Nothing, everything will work OK.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens when you create multiple instances of a class in Python with the same arguments?

Only the last instance created will retain the attribute values.

Each instance will have its own unique memory address and separate attribute values.

The program will throw an error indicating duplicate instances.

Each instance will have the same memory address but separate attribute values.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What attributes are included in the Dog class?

class Dog:

def init(self, name, age):

self.name = name

self.age = age

def sit(self):

print(f'{self.name} is now sitting.')

def roll_over(self):

print(f'{self.name} rolled over!')

name and age

only name

only age

the class dog has no attributes

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you access the attributes of an instance in Python?

By using the getattr() function (getattr(instance, 'attribute'))

By using square bracket notation (instance['attribute'])

By calling a method with the attribute name as an argument (instance.get_attribute('attribute'))

By using dot notation (instance.attribute)

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?