Question
Identify any bug in below code. Explain if its a logical, syntax or run-time error and why. Provide line number of the identified error. If
Identify any bug in below code. Explain if its a logical, syntax or run-time error and why. Provide line number of the identified error. If no errors, write valid code.
class Language:
def speak(self, lang = "English"):
self.lang = lang
return(lang)
class French(Language):
def speak(self):
return(self.lang)
class Canada(Language):
pass
#Object instantiation
x = French()
print(x.speak())
--------------------------------------------------------- (T/F) A docstring is required and should clearly and concisely summarize the purpose of a class or method it is describing.
--------------------------------------------------------- (T/F) The diamond problem is an unique issue that can occur in multiple inheritance but not in single inheritance situation.
---------------------------------------------------------
Identify any bug in below code. Explain if its a logical, syntax or run-time error and why. Provide line number of the identified error(s). If no errors, write valid code.
from math import pi
class MyCircle:
def __init__(self, r):
self.r = r
def circle_area():
return pi * r**2
r = MyCircle(4)
area = circle_area(r)
print (area)
--------------------------------------------------------- (T/F) Multiple inheritance allows a subclass to inherit functionality from multiple parent classes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started