OOPS - Python

OOPS - Python

Assessment

Quiz

Computers

University

Hard

Created by

TMU Gupta

Used 6+ times

FREE Resource

Student preview

quiz-placeholder

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

_____ represents an entity in the real world with its identity and behaviour.

A method

An object

A class

An operator

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What type of inheritance is illustrated in the following Python code?

class A():

pass

class B():

pass

class C(A,B):

pass

Multi-level inheritance

Multiple inheritance

Hierarchical inheritance

Single-level inheritance

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following Python code?


class A:

def __init__(self):

self._x = 5


class B(A):

def display(self):

print(self._x)


def main():

obj = B()

obj.display()


main()

Error, invalid syntax for object declaration

Nothing is printed

5

Error, private class member can’t be accessed in a subclass

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following Python code?

def say(message, times = 1):

print(message * times)


say('Hello')

say('World', 5)

Hello

WorldWorldWorldWorldWorld

Hello

World 5

Hello

World,World,World,World,World

Hello

HelloHelloHelloHelloHello

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following Python code?

def func(a, b=5, c=10):

print('a is', a, 'and b is', b, 'and c is', c)


func(3, 7)

func(25, c = 24)

func(c = 50, a = 100)

a is 7 and b is 3 and c is 10

a is 25 and b is 5 and c is 24

a is 5 and b is 100 and c is 50

a is 3 and b is 7 and c is 10

a is 5 and b is 25 and c is 24

a is 50 and b is 100 and c is 5

a is 3 and b is 7 and c is 10

a is 25 and b is 5 and c is 24

a is 100 and b is 5 and c is 50

Error

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output of the following Python code?

a=10

b=20


def change():

global b

a=45

b=56


change()

print(a)

print(b)

10

56

45

56

10

20

Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How are variable length arguments specified in the function heading?

one star followed by a valid identifier

one underscore followed by a valid identifier

two stars followed by a valid identifier

two underscores followed by a valid identifier

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?