What will be the display output of the following code? class…
What will be the display output of the following code? class Rivers: def __init__(self, itemList): self.riverList = itemList def __iter__(self): return RiverIterator(self.riverList) class RiverIterator: def __init__(self, rlist): self.rlist = rlist self.index = 0 def __next__(self): if self.index >= len(self.rlist): raise StopIteration self.index += 1 return self.rlist[self.index – 1] EuroRivers = [‘Loire’, ‘Seine’, ‘Rhone’, ‘Rhine’, ‘Aare’, ‘Tiber’, ‘Danube’, ‘Thames’]r1 = Rivers(EuroRivers)riverMenu = iter(r1) next(riverMenu))print (next(riverMenu))next(riverMenu))print(next(riverMenu))print(riverMenu))next(riverMenu))next(riverMenu))print(next(riverMenu))print (‘End of rivers’)
Read DetailsFor the class definition below, what could be done to allow…
For the class definition below, what could be done to allow the attribute “__venue” to be directly accessed (“read” access) using dot-notation and the name “venue”? For example, the code to print the venue for Ticket object t1 would be ‘print(t1.venue)’. Check all of the following code choices that would provide a complete solution when added to the Ticket class. class Ticket (object): ticketCount = 0 def __init__(self, name, event, date, venue): Ticket.ticketCount += 1 self.__serialNumber = Ticket.ticketCount self.cust_name = name self.date = date self.__event = event self.__venue = venue
Read DetailsWrite the code for a method in the NFL class (previous quest…
Write the code for a method in the NFL class (previous question) to read the superbowl games in the class object and select the games that were decided by more than a specified point margin. The method takes two parameters: team = ‘all’ or the name of an NFL team that won the game (e.g., ‘Washington’, ‘Baltimore’, etc.) – default is ‘all’ margin = minimum integer point value by which the game must have been decided by – default value is 10 Display the games decided by at least that point margin and matches the winning team parameter or ‘all’, in which case all games where the winning margin exceeded the parameter are selected. Include the year of the game, the winning and losing teams, and each team’s score in the output. Also display as the last line the number of games that were selected. For example, if the method is run with parameters team = ‘Dallas’ and margin = 15, the output would be this: 1972 Dallas 24, Miami 31978 Dallas 27, Denver 101993 Dallas 52, Buffalo 171994 Dallas 30, Buffalo 13 number of games with margin of 15 or more is 4 You do not have to retype the NFL class defined in the answer to a previous question.
Read Details