Search Header Logo

python quiz 4

Authored by karthika karthika

Computers

Professional Development

Used 99+ times

python quiz 4
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Q.1. What is the output of this code?

a,b=1,0

a=a^b

b=a^b

a=a^b

print(a)

0

1

2

error

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

what is output of following code −

class Count:

def __init__(self, count=0):

self.__count=count

a=Count(2)

b=Count(2)

print(id(a)==id(b), end = '' '')


c= ''hello''

d= ''hello''

print(id(c)==id(d))

A - True False

B - False True

C - False False

D - True True

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet?class Sales:

def __init__(self, id):

self.id = id

id = 100


val = Sales(123)

print (val.id)

A. SyntaxError, this program will not run

B. 100

C. 123

D. None of the above

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet?class Person:

def __init__(self, id):

self.id = id


sam = Person(100)


sam.__dict__['age'] = 49


print (sam.age + len(sam.__dict__))

1

2

50

51

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following can be used to invoke the __init__ method in B from A, where A is a subclass of B?

A. super().__init__()

B. super().__init__(self)

C. B.__init__()

D. B.__init__(self)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet?class A:

def __init__(self):

self.calcI(30)

print("i from A is", self.i)


def calcI(self, i):

self.i = 2 * i;


class B(A):

def __init__(self):

super().__init__()

def calcI(self, i):

self.i = 3 * i;


b = B()

A. The __init__ method of only class B gets invoked.

B. The __init__ method of class A gets invoked and it displays “i from A is 0”.

C. The __init__ method of class A gets invoked and it displays “i from A is 60”.

D. The __init__ method of class A gets invoked and it displays “i from A is 90”.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is not a complex number?

a) k = 2 + 3j

b) k = complex(2, 3)

c) k = 2 + 3l

d) k = 2 + 3J

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?