GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Write the display output of the following code in the space…

Write the display output of the following code in the space below. class CarInv: # Inventory for a used car lot – numbers of each model   def __init__ (self, inventory):       self.inventory = inventory     def add (self, **kwargs):       for item in kwargs:           if item in self.inventory:                   self.inventory[item] += kwargs[item]           else:               self.inventory[item] = kwargs[item] def remove (self, car): # car = tuple of (model, qty) if car[0] in self.inventory: if car[1] >= self.inventory[car[0]]: del self.inventory[car[0]] else: self.inventory[car[0]] = self.inventory[car[0]] – car[1]     def showInv(self):       for item in self.inventory:           print (item, ‘ – ‘, self.inventory[item]) originalInv = {‘Acura’: 2, ‘BMW’: 3, ‘Ford’: 11, ‘Honda’: 8, ‘Toyota’: 9}CI = CarInv(originalInv)CI.add(Honda = 2, Ford = 4, Mazda = 3, Toyota = 5, Subaru = 3)CI.remove((‘Toyota’,2) )CI.add(Kia = 2, Toyota = 1)CI.remove((‘BMW’, 3))CI.add( )CI.showInv()

Read Details

Write the complete display output of the following code. cla…

Write the complete display output of the following code. class Employee (object):    def __init__(self, name, email):          self.name = name          self.email = email    def chgEmail (self, newEmail):          self.email = newEmail + ‘.com’          return True class Manager (Employee):      def __init__(self, name, email, salary):          super().__init__(name, email)         self.salary = salary   def chgEmail(self, newEmail):          self.email = newEmail class Worker (Employee):    def __init__(self, name, email, hourly):         super().__init__(name, email)          self.hourly = hourly           # executable code that follows the code above:e1 = Employee (‘John Davis’, ‘jDavis@gmail.com’)e2 = Employee (‘James Bradley J’, ‘jbjones@psu.edu’)w1 = Worker   (‘Karina Walden’, ‘kwalden@state.gov’, 18.50)w2 = Worker   (‘Juan MacMaster’, ‘jmacmaster@gmail.com’, ‘17.25’)m1 = Manager  (‘Warren Buffet’, ‘wbuffet@bhathaway.com’, 92000)m2 = Manager  (‘Erica Contreras’, ‘econtreras@gmail.com’, 110000)m1.chgEmail(‘jbuffet@margaville.com’)print(m1.name, ‘\n’, e1.email, ‘\n$’, str(m2.salary), ‘\n’, m1.email)

Read Details

For the class definition below, add code that would allow th…

For the class definition below, add code that would 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)’.  Hint: use the Python property feature to do this.  Two ways of adding properties were discussed.  Pick one and write the code needed to implement it in the 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 Details

What will be the display output of the following code:class…

What will be the display output of the following code:class DeskTopFile(object):      def __init__ (self, name):              self.name = name + self.suffix      def rightClickProperties (self):              return (‘Show properties for file ‘+self.name)class Txt (DeskTopFile):     suffix = ‘.txt’      def leftClickOpen (self):            return (‘Notepad opening file ‘+self.name)      def rightClickProperties (self):            return (self.name+ ‘ properties are shown below—- ‘)   class Word (DeskTopFile):     suffix = ‘.doc’     def leftClickOpen (self):            return (‘MS Word opening file ‘+self.name)      super( ).rightClickProperties( )class PowerPoint:      suffix = ‘.ppt’      def __init__ (self, name):            self.name = name + PowerPoint.suffix     def leftClickOpen (self):           return (‘Opening PowerPoint file ‘+self.name)# Global code follows———————————————————————————–d1 = Word(‘Essay3’)d2 = Txt(‘Note2’)d3 = PowerPoint(‘Slides’)documents = [PowerPoint(‘Slides1’), Word(‘Essay3’), Txt(‘Note2’))]print (d1.rightClickProperties())print(d2.rightClickProperties())print(d3.leftClickOpen())

Read Details

An example of an Application Program Interface (API) was pre…

An example of an Application Program Interface (API) was presented in class late in the semester.  Which of the following are true about that API?  Check all that are true.

Read Details

For the class definition of Property, below, which of the fo…

For the class definition of Property, below, which of the following definitions correctly sets up a subclass called Apartment that inherits everything from Property and adds its own attributes for ‘rent’ and ‘floor’ (floor space)? class Property (object):        def __init__(self, propID, loc, size, descr):                self.__propID = propID                self.__loc = loc                self.__size = size                self.__descr = descr

Read Details

Which intervention would be most appropriate to target the c…

Which intervention would be most appropriate to target the corresponding underlying factor contributing to obesity?

Read Details

Which statement regarding Torsades de Pointes (TdP) is corre…

Which statement regarding Torsades de Pointes (TdP) is correct?

Read Details

The following structure is an intermediate produced during t…

The following structure is an intermediate produced during the β-oxidation of a fatty acid. Which enzyme is able to use it as a substrate?

Read Details

Which of the following participants in the glucagon signalin…

Which of the following participants in the glucagon signaling cascade directly cleave triacylglycerols to release free fatty acids in adipocytes?

Read Details

Posts pagination

Newer posts 1 … 24,751 24,752 24,753 24,754 24,755 … 96,882 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top