Write a program that does the following in Python Code:
Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point.
//////////////////////////////////////////////////////
from datetime import datetime
class Famous_Person(object):
def __init__(self, last, first, month,day, year):
self.last = last
self.first = first
self.month = month
self.day = day
self.year = year
def __str__(self):
template = "{first} {last} was born on the
{month}/{day}/{year}"
return template.format(
first=self.first,
last=self.last,
month=self.month,
day = self.day,
year = self.year)
class Famous_Person_Day(Famous_Person):
def calculate_day(self):
#insert your code here
# The method creates a datetime class of the Famous_person
birthdate
# and returns the weekday of the birthdate.
def find_day(self):
#insert your code here
# calls calculate_day to find weekday
# and uses if-statement to finds and returns the actual
weekday
def main():
george_w = Famous_Person_Day(last="Washington",
first="George",
month = 2,
day = 22,
year = 1732
)
isaac_n = Famous_Person_Day(last="Newton",
first="Isaac",
month = 1,
day = 4,
year = 1643
)
albert_e = Famous_Person_Day(last="Einstein",
first="Albert",
month = 3,
day = 14,
year = 1879
)
print(george_w)
wday = george_w.find_day()
print (wday)
#Print a blank line
print()
print(isaac_n)
wday = isaac_n.find_day()
print (wday)
#Print a blank line
print()
print(albert_e)
wday = albert_e.find_day()
print (wday)
if __name__ == "__main__":
main()
////////////////////////////////////////////
Test your code and make sure it is error-free and works correctly.
If you have any doubts, please give me comment...




Code:
from datetime import datetime
class Famous_Person(object):
def __init__(self, last, first, month,day, year):
self.last = last
self.first = first
self.month = month
self.day = day
self.year = year
def __str__(self):
template = "{first} {last} was born on the {month}/{day}/{year}"
return template.format(
first=self.first,
last=self.last,
month=self.month,
day = self.day,
year = self.year)
class Famous_Person_Day(Famous_Person):
def calculate_day(self):
#insert your code here
# The method creates a datetime class of the Famous_person birthdate
# and returns the weekday of the birthdate.
return datetime(self.year, self.month, self.day).weekday()
def find_day(self):
#insert your code here
# calls calculate_day to find weekday
# and uses if-statement to finds and returns the actual weekday
day = self.calculate_day()
if day==0:
return 'Monday'
elif day==1:
return 'Tuesday'
elif day==2:
return 'Wednesday'
elif day==3:
return 'Thursday'
elif day==4:
return 'Friday'
elif day==5:
return 'Saturday'
elif day==6:
return 'Sunday'
def main():
george_w = Famous_Person_Day(last="Washington", first="George", month = 2, day = 22, year = 1732)
isaac_n = Famous_Person_Day(last="Newton", first="Isaac", month = 1, day = 4, year = 1643)
albert_e = Famous_Person_Day(last="Einstein", first="Albert", month = 3, day = 14, year = 1879)
print(george_w)
wday = george_w.find_day()
print (wday)
#Print a blank line
print()
print(isaac_n)
wday = isaac_n.find_day()
print (wday)
#Print a blank line
print()
print(albert_e)
wday = albert_e.find_day()
print (wday)
if __name__ == "__main__":
main()
Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born...
Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point. ////////////////////////////////////////////////////// from datetime import datetime class Famous_Person(object): def __init__(self, last, first, month,day, year): self.last = last self.first = first self.month = month...
How do I make my code print out the text in the ServiceNotifier class? Python Code: class ServiceNotifier: #Subject responsible for notifying registered observer objects Observer = [Email, SMS, Phone] def attach(self): #add new observer Observer.append(insertnewobserverhere) def dettach(self): #remove an observer Observer.pop(insertnewobserverhere) def servicenotifier(self): for observers in Observer: print("Due to the forecast for tomorrow, all university and campus operations will be closed.") ...
### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """ Computes the minimum and maximujm grades from grades and creates a list of two student names: first name is the student with minimum grade and second name is the student with the maximum grade. grades: list of non-negative integers names: list of strings Returns: list of two strings """ def main(): """ Test cases for minmaxgrades() function """ input1 = [80, 75, 90, 85,...
11p
Python Language
Read the following code for oofraction. import oofraction class OOFraction: def main(): fl = oofraction.o0Fraction( 2, 5) f2 = oofraction.o0Fraction ( 1, 3) f3 = f1 + f2 print (str(3)) main() def __init__(self, Num, Den): self.mNum = Num self.mDen = Den return def_add_(self,other): num = self.mNumother.mDen + other.mNum*self.mDen den = self.mDen*other.mDen f = OOFraction(num,den) return f 1. Write the output below. def_str_(self): s = str( self.mNum )+"/" + str( self.mDen) returns 2. Write a class called wholeNum...
***IN PYTHON 2.7****Augment the following code with a new class named 'Coin'. Coin should inherit from Die, with the following modifications; The constructor should not take any arguments; a coin always has two sides add a flip() method that uses the roll() method from the parent class. If roll returns 1; flip should return "HEADS". If roll returns a 2, flip should return "TAILS" Do not override the roll or rollMultiple methods from the parent class #!/usr/bin/python # your class...
PYTHON: Conan is writing a module to contain different implementations of trees. After his first tree, the BinaryTreeclass, he wrote test code and is having problems understanding the error. Locate his problem and explain how you would fix it. class Node(object): def __init__(self, data=None): self.data = data def __str__(self): return "NODE: " + str(self.data) class Tree(object): def __init__(self): self.root_node = None self.size = 0 def __len__(self): return self.size def add(self, data): raise NotImplementedError("Add method not implemented.") def inorder_traversal(self): raise NotImplementedError("inorder_traversal...
PYTHON 3.6 Overview In this assignment we implement a class called TripleString. It consists of a few instance attribute and a few instance methods to support those attributes. In the next assignment, the TripleString class will help us create a more involved application. Before we do that though, we have to thoroughly test our TripleString implementation. Specifications The class TripleString will contain symbolic constants, instance attributes, and instance methods. ▶ Class symbolic constants This class has 3 symbolic constants, which...
PYTHON The provided code in the ATM program is incomplete. Complete the run method of the ATM class. The program should display a message that the police will be called after a user has had three successive failures. The program should also shut down the bank when this happens. [comment]: <> (The ATM program allows a user an indefinite number of attempts to log in. Fix the program so that it displays a message that the police will be called...
I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import arithmetic as a def multiply(num1, num2): product = num1 * num2 result = a.add(product, product) return result def main(): num1 = 4 num2 = 3 answer = multiply(num1, num2) print("The answer is", answer) if __name__ == "__main__": main() arithmetic module: def add(x, y): z = x + y return z Refer to Code...
Python has the complex class for performing complex number arithmetic. For this assignment, you will design and implement your own Complex class. Note that the complex class in Python is named in lowercase, while our custom Complex class is named with C in uppercase. A complex number is of the form a + bi, where a and b are real numbers and i is √-1. The numbers a and b are known as the real part and the imaginary part...