Search Header Logo

Module5_Classes

Authored by Sumathi K

Education

Professional Development

Used 1+ times

Module5_Classes
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

13 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the correct syntax to define a class in Python?

def Student:

class Student():

class Student[]:

create class Student:

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the purpose of the __init__ method in a class?

It deletes the object

It is used to print data

It is the constructor method to initialize object state

It is called when the object is deleted

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What will be the output of the following code?

class Test:

def init(self):

self.val = 10

t = Test()

print(t.val)

0

10

None

Error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a pure function in Python?

A function that modifies the global state

A function that has no return value

A function that does not modify any object or global variable and always returns the same output for same input

A function that takes no parameters

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def add(x, y):

return x + y

What Kind of Function is this?

Pure Function

Modifiers

Both

None

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

def append_item(lst, item):

lst.append(item)

What Kind of function is this?

Class Method

Modifier

Function Definition to append element to a list

Both B and C

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Media Image

In the Object Diagram shown, Which of the following is true?

Class : time

Object : Time

Class : Time

Object : time

Class : Time

Object : time

Attributes: hour min sec

Both B and C

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?