In Python
Exercise – Overriding
class Address:
def __init__(self, street, num):
self.street_name = street
self.number = num
Now make a subclass of the class Address called CampusAddress that has a new attribute, office number, that can vary. This subclass will always have the street attribute set to Massachusetts Ave and the num attribute set to 77. Use the class as follows:
>>> Sarina_addr = CampusAddress("32-G904")
>>> Sarina_addr.office_number
’32G-904’
>>> Sarina_addr.street_name
’Massachusetts Ave’
>>> Sarina_addr.number
77
Given below is the code for the question. PLEASE MAKE SURE
INDENTATION IS EXACTLY AS SHOWN IN IMAGE.
Please do rate the answer if it helped. Thank you.
class Address:
def __init__(self, street, num):
self.street_name = street
self.number = num
class CampusAddress(Address):
def __init__(self, off_num):
Address.__init__(self,
"Massachusetts Ave", 77)
self.office_number = off_num
Sarina_addr = CampusAddress("32-G904")
print(Sarina_addr.office_number)
print(Sarina_addr.street_name)
print(Sarina_addr.number)

In Python Exercise – Overriding class Address: def __init__(self, street, num): self.street_name = street ...
In python class Customer: def __init__(self, customer_id, last_name, first_name, phone_number, address): self._customer_id = int(customer_id) self._last_name = str(last_name) self._first_name = str(first_name) self._phone_number = str(phone_number) self._address = str(address) def display (self): return str(self._customer_id) + ", " + self._first_name + self._last_name + "\n" + self._phone_number + "\n" + self._address customer_one = Customer("694", "Abby", "Boat", "515-555-4289", "123 Bobby Rd", ) print(customer_one.display()) customer_two = Customer ("456AB", "Scott", "James", "515-875-3099", "23 Sesame Street Brooklyn, NY 11213") print(customer_two.display()) Use Customer class remove the address attribute.Place the code...
In Python: Which keyword should be replaced instead of X? class Class(Car): def __init__ (self,arg1,arg2): X.__init__(arg1,arg2) Question 21 options: class def super() super
In PYTHON: Assume there is a class Animal, containing a method with the header: def __init__(self). What statement will create an Animal object and store it in the variable 'cat'.
PYTHON
--------------------------------------------------------
class LinkedList:
def __init__(self):
self.__head = None
self.__tail = None
self.__size = 0
# Return the head element in the list
def getFirst(self):
if self.__size ==
0:
return
None
else:
return
self.__head.element
# Return the last element in the list
def getLast(self):
if self.__size ==
0:
return
None
else:
return
self.__tail.element
# Add an element to the beginning of the
list
def addFirst(self, e):
newNode = Node(e) #
Create a new node
newNode.next =
self.__head # link...
In Python: Which one is the arguments of the ShowInfo method? class Car(): def __init__(self,model, year): self._model = model self._year = year def ShowInfo( ): print(self._model + str(self._year)) Question 16 options: model, year No argument is needed self,model, year self
How to convert this python to c++? class SOMENode: def __init__(self, name, parent, verbose=False): self.name = name self.parent = parent self.children = [] if self.parent: self.parent.add_child(self) self.verbose = verbose
in
python and according to this
#Creating class for stack
class My_Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def Push(self, d):
self.items.append(d)
def Pop(self):
return self.items.pop()
def Display(self):
for i in reversed(self.items):
print(i,end="")
print()
s = My_Stack()
#taking input from user
str = input('Enter your string for palindrome checking:
')
n= len(str)
#Pushing half of the string into stack
for i in range(int(n/2)):
s.Push(str[i])
print("S",end="")
s.Display()
s.Display()
#for the next half checking the upcoming string...
Python 3> Make a class called BMW: Parameterized constructor with three instance variables (attributes): Hint: def __init__(self, make, model, year) Methods in BMW parent class (can leave as method stubs for now): startEngine() -must print "The engine is now on." stopEngine() -must print "The engine is now off." Make another class called ThreeSeries -Must inherit BMW Hint: class ThreeSeries(BMW): -Also passes the three attributes of the parent class and invoke parent Hint: BMW.__init__(self, cruiseControlEnabled, make, model, year) -Constructor must have...
Here is a Python program. import turtle class Box: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height def show(self): turtle.up() turtle.goto(x, y) turtle.down() for _ in range(2): turtle.forward(width) turtle.right(90) turtle.forward(height) turtle.right(90) bigbox = Box(-100, -150, 200, 300) bigbox.show() turtle.done() If you run the above program, it will produce an error. What is the keyword that has...
PYTHON 3.8 class student(): def __init__(self, name = 'Bill', grade = 9, subjects = ['math','science']): self.name = name self.grade = grade self.subjects = subjects def add_subjects(self): print('Current subjects:') print(self.subjects) more_subjects = True while more_subjects == True: subject_input = input('Enter a subject to add: ') if subject_input == '': more_subjects = False print(self.subjects) else: self.subjects.append(subject_input) print(self.subjects) m = student()...