(PP-7)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). i. Write a method called add which returns the sum of the attributes x and y. ii. Write a class method called multiply, which takes a single number parameter a and returns the product of a and MULTIPLIER. iii. Write a static method called subtract, which takes two number parameters, b and c, and returns b - c. iv. 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.
7A . #calculator.py class number: multiplier=3 def __init__(self,x,y): self.x=x self.y=y def add(self): return self.x+self.y def multiply(self,a): return self.multiplier*a def subtract(b,c): return b-c T=number(2,4) print(T.add()) print(T.multiply(2)) print(number.subtract(4,2)) 7B.design the class that stores the info of students and display the same class student: def __init__(self,name,roll_no,address): self.name=name self.roll_no=roll_no self.address=address s=student("Bhavesh",406,"malad") print(s.name) print(s.roll_no) print(s.address) 7C.create a module student_details with functions display_name, marks_total & create new file that imports the module and display the functions. #student_details.py def display_name(Name): print("student Name:",Name) return def marks_total(p,c,m): print("Total marks obtained by student:",p+c+m) ret...
Comments
Post a Comment