How do you do this?
class Event:
"""A new calendar event."""
def __init__(self, start_time: int, end_time: int, event_name:
str) -> None:
"""Initialize a new event that starts at start_time, ends at
end_time,
and is named name.
Precondition: 0 <= start_time < end_time <= 23
>>> e = Event(12, 13, 'Lunch')
>>> e.start_time
12
>>> e.end_time
13
>>> e.name
'Lunch'
"""
self.start_time = start_time
self.end_time = end_time
self.name = event_name
def __str__(self) -> str:
"""Return a string representation of this event.
>>> e = Event(6, 7, 'Run')
>>> str(e)
'Run: from 6 to 7'
"""
return '{0}: from {1} to {2}'.format(self.name,
self.start_time,
self.end_time)
class Day:
"""A calendar day and its events."""
def __init__(self, day: int, month: str, year: int) ->
None:
"""Initialize a day on the calendar with day, month and year,
and no events.
>>> d = Day(5, 'April', 2014)
>>> d.day
5
>>> d.month
'April'
>>> d.year
2014
>>> d.events
[]
"""
# To do: Complete this method body.
Code:
class Event:
"""A new calendar event."""
def __init__(self, start_time: int, end_time: int, event_name: str) -> None:
"""Initialize a new event that starts at start_time, ends at end_time,
and is named name.
Precondition: 0 <= start_time < end_time <= 23
>>> e = Event(12, 13, 'Lunch')
>>> e.start_time
12
>>> e.end_time
13
>>> e.name
'Lunch'
"""
self.start_time = start_time
self.end_time = end_time
self.name = event_name
def __str__(self) -> str:
"""Return a string representation of this event.
>>> e = Event(6, 7, 'Run')
>>> str(e)
'Run: from 6 to 7'
"""
return '{0}: from {1} to {2}'.format(self.name, self.start_time, self.end_time)
class Day:
"""A calendar day and its events."""
def __init__(self, day: int, month: str, year: int) -> None:
"""Initialize a day on the calendar with day, month and year,
and no events.
>>> d = Day(5, 'April', 2014)
>>> d.day
5
>>> d.month
'April'
>>> d.year
2014
>>> d.events
[]
"""
self.day = day
self.month = month
self.year = year
self.events = []
def ScheduleEvent(self, e: "Event") -> None:
"""Schedule new_event on this day, even if it overlaps with
an existing event. Later we will improve this method.
>>> d = Day(5, 'April', 2014)
>>> e = Event(6, 7, 'Run')
>>> d.schedule_event(e)
>>> d.events[0] == e
True
"""
self.events.append(e)
def __str__(self) -> str:
"""Return a string representation of this day.
>>> d = Day(4, 'April', 2014)
>>> d.schedule_event(Event(12, 13, 'Lunch'))
>>> d.schedule_event(Event(6, 7, 'Run'))
>>> print(d)
4 April 2014:
- Lunch: from 12 to 13
- Run: from 6 to 7
"""
outputStr = "{:d} {:s} {:d}".format(self.day, self.month, self.year)
for e in self.events:
outputStr += "\n- {:s}".format(str(e))
return outputStr

Output:

How do you do this? class Event: """A new calendar event.""" def __init__(self, start_time: int, end_time:...
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
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...
ill thumb up do your best
python3
import random
class CardDeck:
class Card:
def __init__(self, value):
self.value = value
self.next = None
def __repr__(self):
return "{}".format(self.value)
def __init__(self):
self.top = None
def shuffle(self):
card_list = 4 * [x for x in range(2, 12)] + 12 * [10]
random.shuffle(card_list)
self.top = None
for card in card_list:
new_card = self.Card(card)
new_card.next = self.top
self.top = new_card
def __repr__(self):
curr = self.top
out = ""
card_list = []
while curr is not None:...
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...
class Leibniz: def __init__(self): self.total=0 def calculate_pi(self,n): try: self.total, sign = 0, 1 for i in range(n): term = 1 / (2 * i + 1) self.total += term * sign sign *= -1 self.total *= 4 return self.total except Exception as e: ...
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...
COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree: class treeNode: def __init__(self, value, lchild, rchild): self.value, self.lchild, self.rchild = value, lchild, rchild def __init__(self): self.treeRoot = None #utility functions for constructTree def mask(self, s): nestLevel = 0 masked = list(s) for i in range(len(s)): if s[i]==")": nestLevel -=1 elif s[i]=="(": nestLevel += 1 if nestLevel>0 and not (s[i]=="(" and nestLevel==1): masked[i]=" " return "".join(masked) def isNumber(self, expr): mys=s.strip() if len(mys)==0 or not isinstance(mys, str): print("type mismatch error: isNumber")...
class Bool(Expr): """A boolean constant literal. === Attributes === b: the value of the constant """ b: bool def __init__(self, b: bool) -> None: """Initialize a new boolean constant.""" self.b = b # TODO: implement this method! def evaluate(self) -> Any: """Return the *value* of this expression. The returned value should the result of how this expression would be evaluated by the Python interpreter. >>> expr = Bool(True) >>> expr.evaluate() True """ return self.b def __str__(self) -> str: """Return a...
Can you complete the following
code, please? Thank you.
class BinaryNode:
def __init__(self, value):
self.__value = value
self.__left = None
self.__right = None
self.__parent = None
self.__height = 1
def getValue(self):
return self.__value
def setHeight(self, height):
self.__height = height
def getHeight(self):
return self.__height
def setParent(self, node):
self.__parent = node
def getParent(self):
return self.__parent
def setLeftChild(self, child):
self.__left = child
child.setParent(self)
def setRightChild(self, child):
self.__right = child
child.setParent(self)
def createLeftChild(self, value):
self.__left = BinaryNode(value)
def createRightChild(self, value):
self.__right = BinaryNode(value)
def...
Question 3. [16 MARKS] Part (a) [4 MARKS Complete the Car class below. class Car: A Car class. we Attributes plate: this car's license plate number odometer: how many km this car has been driven in total plate: str odometer: int # TO DO: COMPLETE THE INITALIZER BELOW def __init__(self, plate: str) -> None: "Initialize a new Car with the given <plate>, and Okm on the odometer. >>> ci - Car ("AAA 111") >>> c1.plate "AAA 111" >>> ci.odometer #...