Answer to Question #229790 in Python for Lia

Question #229790

class PriceChecker():

# Constructor

def __init__(self):

self.levelsList = []

# Properties

@property

def levelsList(self):

return self.__levelsList

@levelsList.setter

def levelsList(self, newValue):

self.__levelsList = newValue

# Class Methods

# =============

# Method: Sort and Display the levelsList

def displayList(self):

print(chr(27) + "[2J") # Clear the screen

print("Price Levels In The List")

print("========================")

# Sort the list in reverse order

...

# Print the items in the list (Based on the above sort, numbers should appear from large to small.)

...


Instructions: Replace the ellipsis "..." with code


1
Expert's answer
2021-08-26T02:27:19-0400
class PriceChecker():
    # Constructor 
    def __init__(self):
        self.levelsList = []

    @property
    def levelsList(self):
        return self.__levelsList
    @levelsList.setter
    def levelsList(self, newValue):
        self.__levelsList = newValue 
    def sortLevels(self):
        self.__levelsList.sort()   

    # Class Methods
    # =============

    # Method: Sort and Display the levelsList
    def displayList(self):
        print(chr(27) + "[2J") # Clear the screen
        print("Price Levels In The List")
        print("========================")
        # Sort the list in reverse order
        return print(sortLevels())
        # Print the items in the list (Based on the above sort, numbers should appear from large to small.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS