Assignment Detail

  1. Home
  2. Assignment Instructions
Tutors

What is it called when a class inherits a derived classAnswered

Assignment Instructions

Assignment Help >> Python Programming

Answer the following Questions

1. What is it called when one class is derived from another single class?

1 Simple inheritance
2 Multiple inheritance
3 Multi-level inheritance
4 Single inheritance
5 None of these.

2. What does the following class definition portrays?
class Rect(Shape):
def init (self,x,y): Shape. init (self,x,y)

1 A single inheritance where class Rect inherits class Shape.
2 A single inheritance where class Shape inherits class Rect.
3 There is no inheritance.
4 None of these

3. What is it called when a derived class has got more than one base class?

1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these

4. Which of the given code segments will print the area of an object r1 of class Rect as 12 correctly?

1 class Shape:
def init (self, x,y): self. l=x
self. b=y def area(self):
return self. l * self. b
class Rect(Shape):
def init (self,x,y):

Shape. init (self,x,y) r1=Rect(3,4) print(“Area:”, r1.area())
2 class Shape:
def init (self, x,y): self. l=x
self. b=y def area(self):
return self. l * self. b
class Rect(Shape):
def init (self,x,y):

Shape. init (self,x,y) r1=rect(3,4) print(“Area:”, r1.l * r1.b)
3 Both 1 and 2
4 None of these
5. b=[2,6,8]. Of what type of variable is b an example?

1 string
2 tuple
3 list
4 None of these

6. Which of the given code segments will print the area of an object s of class Square as 144 correctly?

1 class Square:
def init (self, a): self. a=a
s=Square(12)
print(s._Square a * s._Square a)
2 class Square:
def init (self, a): self. a=a
s=Square(12)
print(s. a * s a)
3 class Square:
def init (self, a): self. a=a
s=Square(12)
print(s.Square a * s.Square a)
4 None of these

7. In the following code n1 is an object of the derived class Num1. What is the output?
class Num:
def init (self): self.a=2 self.b=3
def calc(self):
return self.a*self.b class Num1(Num):
def init (self): Num. init (self)
def calc(self):
return self.a+self.b n1=Num1()
print(n1.calc())

1 2
2 3
3 5
4 6

8. In the following code n1 is an object of the derived class Num1. What is the output?
class Num:
def init (self): self.a=2
self.b=3
def calc(self): return self.a*self.b
class Num1(Num):
def init (self): Num. init (self)
def calc(self): print(Num.calc(self),end=
‘ ‘)
print(self.a+self.b) n1=Num1()
n1.calc()

1 2 3
2 3 2
3 6 5
4 5 6

9. What is it called when a class inherits a derived class?

1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these

10. What type of inheritance does the following code snippet demonstrate?
class A:
pass class B(A):
pass class C(B):
pass

1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these

11. What type of inheritance does the following code snippet demonstrate?
class A:
pass class B:
pass class C(A,B):
pass

1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these

12. What is the output of the following code?

class A:
def display(self): print(“Calling method of Class A”)
class B():
def display(self): print(“Calling method of Class B”)
class C(B,A): pass
obj=C()
obj.display()

1 Calling method of Class A
2 Calling method of Class B
3 pass
4 None of these

13. Which statement is false?

1 For data that are owned by individual objects of a class, you must use class variables.
2 A derived class can have more than one parent.
3 You can add, subtract, multiply and divide class instances.
4 To maintain data that is held in common by all objects of a class, you should use class variables.

14. Which of the given code fragments facilitate the addition of two instances of class A?

1 class A:
def init (self): self.x=20;
def add(self, other): return self.x+other.x
a1=A()
a2=A()
a3=a1+a2
2 class A:
def init (self): self.x=20;
a1=A()
a2=A()
a3=a1+a2

3 class A:
def init (self): self.x=20;
def add (self, other): return self.x+other.x
a1=A()
a2=A()
a3=a1+a2
4 All the above

15. Which method should be implemented into the class when two instances of a class are compared by using the == operator?

1 isequal
2 equal
3 eq
4 None of these
16. What is the output of the following code?
class Subject(object):
def init (self,mark): self.mark=mark
def set_mark(self, mark): if mark < 0:
self.mark = 0 elif mark > 100:
self.mark = 100 else:
self.mark = mark def get_mark(self):
return self.mark

m=property(get_mark,set_mark) s=Subject(70)
s.m=102
print(s.m)

1 70
2 102
3 100
4 None of these

17. What is a class called that implements special methods like set , get or delete ?

1 Super class
2 descriptor
3 Sub-class
4 None of these

18. What do you call a class that implements only the get method for an object?

1 non-data-descriptor
2 data descriptor
3 getter class
4 None of these

19. What is a class called that implements the set method for an object?

1 non-data-descriptor
2 data descriptor
3 setter class
4 None of these

20. What is the output of the following code?

class Desc(object): def init (self):
self._name = ”
def
get (self,instance,owner): return self._name
def
set (self,instance,value): self._name =
value.title()
class Person(object): nameObj = Desc()
p = Person()
p.nameObj = ‘Mr. daniel johnson’ print(p.nameObj)

1 Mr. daniel johnson
2 Mr
3 Mr. Daniel Johnson
4 None of these

Verified Tutor Answer

Plagiarism Checked

Asked by: Anonymous

Answer Rating:
4.6/5
Subscribe to any of the below Membership Plans to Access Answer Files

Popular Plans

Members will get 30% OFF on all their Assignments. Use FLAT30 coupon while making payment for assignments.

Semester
$59.99 / 6 Months
Benefits:
  • Questions you can ask

    50 
  • Urgent Assignment (Solution within 24 Hours)

    25 
  • Plagiarism Free

     
  • Duration

    180 Days
  • Chat with Tutor

     
Quarterly
$39.99 / 3 Months
Benefits:
  • Questions you can ask

    30 
  • Urgent Assignment (Solution within 24 Hours)

    15 
  • Plagiarism Free

     
  • Duration

    90 Days
  • Chat with Tutor

     
Monthly
$14.99 / 1 Month
Benefits:
  • Questions you can ask

    15 
  • Urgent Assignment (Solution within 24 Hours)

  • Plagiarism Free

     
  • Duration

    30 Days
  • Chat with Tutor

     
Gold
$30 / 1 Month
Benefits:
  • No of credits

    300 
  • No of Services

    15 
  • No of Featured Services

    10 
  • Badge

    Gold 
  • Plagiarism Free

     
  • Duration

    30 Days
  • No of skills

    25 
  • Chat with Tutor

     
Platinum
$17 / 1 Month
Benefits:
  • No of credits

    250 
  • No of Services

    10 
  • No of Featured Services

  • Badge

    Platinum 
  • Plagiarism Free

     
  • Duration

    30 Days
  • No of skills

    20 
  • Chat with Tutor

     
Premium
$10 / 1 Month
Benefits:
  • No of credits

    100 
  • No of Services

  • No of Featured Services

  • Badge

    Premium 
  • Plagiarism Free

     
  • Duration

    30 Days
  • No of skills

  • Chat with Tutor

     

Similar Assignments

Unit 3 Human Resources Management Assignment

Reference no: EM132405429 Unit 3 Human Resources Management Assignment – TNA67 Pearson BTEC HND in Business (RQF) – ICON College of Technology and Management, London, England, UK Assignment Context and Scenario: As a newly appointed Human Resource Manager for your chosen UK-based organisation, you have been tasked with leading on

View Complete Question »

How to locate the footnotes in the financial statements

Reference no: EM132643341 ACCT3332 Intermediate Financial Accounting – University of Texas at Dallas Assignment Requirements Per the syllabus, the Footnote Assignment requirements are as follows: Choose a public company and access the 10-K Filing at webiste sec. Click “Company Filings” in the top-right corner and search by company name. Look

View Complete Question »

Record these transactions into a general journal

Assignment ID: FG133006040 Question – Kevin opened Webdesign Service on 1 April 2020. The following five (5) transactions occurred during the first month of operations: -Kevin, the owner, invested $50,000 cash into the business. -Purchased a 1-year insurance policy for $8,000. The business received an invoice and paid in cash.

View Complete Question »
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. You can send Assignments directly to support team.
👋 Hi, how can I help?