The program below reads the entire content of the file, assuming the file path exists and is correct as specified. fp = open(‘input.txt’, ‘r’) fp.readlines() fp.close()
Blog
View the following class definition then answer the question…
View the following class definition then answer the question that follows. class Date ( ): currentYear = 2024 def __init__ (self, month, day, descr): self.month = month self. day = day self.descr = descr def __str__ (self): return str(self.month) + ‘/’ + str(self.day) + ‘/’ + str(self.year) + ‘ – ‘ + self.descr What changes can be done to make the above code function correctly by printing a 2024 date with the Python ‘print’ statement? Check the statements that, each executed by itself (that is, not in combination with another statement), would make the code correctly execute.
What is printed by the following? def receipt (items): …
What is printed by the following? def receipt (items): for n in range(len(items)): print(n, items[n]) ilist = [‘milk’, ‘eggs’, ‘bread’] receipt (ilist)
View the following class definition, then answer the questio…
View the following class definition, then answer the question that follows. class Date ( ): def __init__ (self, month, day, descr): self.month = month self. day = day self.descr = descr def __str__ (self): return str(self.month) + ‘/’ + str(self.day) + ‘/’ + str(self.year) + ‘ – ‘ + self.descr What changes should be done to the above code so that its objects include a year as an attribute? Check all that must be done.
View the following class definition, then answer the questio…
View the following class definition, then answer the question that follows. class Date ( ): def __init__ (self, day, month, year, descr): self.month = month self. day = day self.year = year self.descr = descr def __str__ (self): return str(self.month) + ‘/’ + str(self.day) + ‘/’ + str(self.year) + ‘ – ‘ + self.descrd1 = Date(’01’, ’04’, ‘2025’, ‘Important date’)print(d1) What is the display output of the above code?
View the following class definition, then answer the questio…
View the following class definition, then answer the question that follows. class Date ( ): def __init__ (self, month, day, year, descr): self.month = month self. day = day self.year = year self.descr = descr def __str__ (self): return str(self.month) + ‘/’ + str(self.day) + ‘/’ + str(self.year) + ‘ – ‘ + self.descrd1 = Date(’08’, ’26’, ‘2024’, ‘Start of semester’)print(d1.month)print(d1) Which of the following is true about the above code? Check all that are true.
Given the following class code that you should assume will c…
Given the following class code that you should assume will correctly execute (ignore any minor syntax errors): class Ticket (object): def __init__ (self, name, event, serialNo): self.cust_name = name self.event = event self.serialNumber = serialNo def __str__ (self): return (‘Tick for ‘ + self.cust_name + ‘ – ‘ + self.event) # global code ———————————————-t1 = Ticket (‘Molly Smith’, ‘Concert’, ‘a250’)t2 = Ticket (‘Tom Brady’, ‘Bucs Game’, ‘NFL0100’)t3 = Ticket (‘Mike Rizzo’, ‘Nats Game’, ‘WS2023’)t4 = Ticket (‘E. Musk’, ‘SpaceX Launch’,’NASA2021′)t5 = Ticket (‘K. Ball’, ‘GMU Basketball’,’Pats11293′)t6 = Ticket (‘A. Trebek’, ‘Jeopardy Audience’,’Historyfor1000′)t1.event = ‘Opera’What is the display output of print (t1) ?
Given the following class code that you should assume will c…
Given the following class code that you should assume will correctly execute (ignore any minor syntax errors): class Ticket (object): ticketCount = 0 def __init__ (self, name, event): self.serialNumber = Ticket.ticketCount Ticket.ticketCount += 1 self.cust_name = name self.event = event def __str__ (self): return (‘Tick#’ + str(self.serialNumber) + ‘ – ‘ + self.cust_name + ‘ – ‘ + self.event) def equalTick (self, t_obj): if self == t_obj: return True, ‘dupe ticket’ if not isinstance (t_obj, Ticket): return False, ‘Object not type Ticket’ return (str(self.serialNumber) == str(t_obj.serialNumber) and str(self.event) == str(t_obj.event), ‘comparison done’ )# global code ———————————————-t1 = Ticket (‘K. Ball’, ‘GMU Basketball’)t2 = Ticket (‘Tom Brady’, ‘Pats Game’)t3 = Ticket (‘Gene Shuman’, ‘Nats Game’)t4 = Ticket (‘E. Musk’, ‘SpaceX Launch’)t5 = Ticket (‘K. Ball’, ‘GMU Basketball’)t6 = Ticket (‘A. Trebek’, ‘Jeopardy Audience’)What is the display output of t1 == t5 ?
Read the following code then check all the statements that a…
Read the following code then check all the statements that are true concerning the code. class Date ( ): def __init__ (self, month, day, year): self.__month = month self.__day = day self.__year = year Assume code that uses the above class has created a Date object and assigned it variable id d1.
Given the following class code that you should assume will c…
Given the following class code that you should assume will correctly execute (ignore any minor syntax errors): class Ticket (object): ticketCount = 10 def __init__ (self, name, event): self.serialNumber = Ticket.ticketCount Ticket.ticketCount += 1 self.cust_name = name self.event = event def __str__ (self): return (‘Tick#’ + str(self.serialNumber) + ‘ – ‘ + self.cust_name + ‘ – ‘ + self.event) def equalTick (self, t_obj): if self == t_obj: return True, ‘dupe ticket’ if not isinstance (t_obj, Ticket): return False, ‘Object not type Ticket’ return (str(self.serialNumber) == str(t_obj.serialNumber) and str(self.event) == str(t_obj.event), ‘comparison done’ )# global code ———————————————-t1 = Ticket (‘K. Ball’, ‘GMU Basketball’)t2 = Ticket (‘Tom Brady’, ‘Pats Game’)t3 = Ticket (‘Gene Shuman’, ‘Nats Game’)t4 = Ticket (‘E. Musk’, ‘SpaceX Launch’)t5 = Ticket (‘K. Ball’, ‘GMU Basketball’)t6 = Ticket (‘A. Trebek’, ‘Jeopardy Audience’)t7 = ‘Tick#7 – Gene Shuman – Nats Game’What is the display output of print (Ticket.ticketCount) ?