Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

PLEASE USE PYTHON PROGRAMMING

 

Create a class called Numbers, which has a single class attribute called MULTIPLIER, and a constructor which takes the parameters x and y (these should all be numbers).

  1. Write a method called add which returns the sum of the attributes x and y.
  2. Write a class method called multiply, which takes a single number parameter aand returns the product of a and MULTIPLIER.
  3. Write a static method called subtract, which takes two number parameters, b and c, and returns b - c.
  4. Write a method called value which returns a tuple containing the values of x and y. Make this method into a property, and write a setter and a deleter for manipulating the values of x and y.

 

class Numbers:
    # TODO: create a class attribute called MULTIPLIER
    
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def add(self):
        # TODO: return x + y

    def multiply(self, a):
        # TODO: return the attribute MULTIPLIER * by a.

    @staticmethod
    def subtract(b, c):
        # TODO: 

    # TODO: Make this a property
    def value(self):
        return self.x, self.y

    # TODO: Create a setter and a deleter for value.

# test the class.
num = Numbers(5,6)
print(num.add())
print(num.multiply(2))
print(num.subtract(4, 4))

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY