B02C-2017D – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12D-2017-B02C #PYTHON#6409    siteicon   siteicon  

Problem Statement - B02C-2017D

Define a class RING in Python with following specifications

Instance Attributes
- RingID  # Numeric value with a default value 101
- Radius  # Numeric value with a default value 10
- Area    # Numeric value
Methods:
- AreaCal()  # Method to calculate Area as
             # 3.14*Radius*Radius
- NewRing()  # Method to allow user to enter values of
             # RingID and Radius. It should also
             # Call AreaCal Method
- ViewRing() # Method to display all the Attributes

Solution

TC++ #6409

class RING: # OR class RING( ): OR class RING(Object):
    def __init__(self):
        self.RingID=101
        self.Radius=10
        self.Area=0
    def AreaCal(self):
        self.Area=3.14*self.Radius*self.Radius
    def NewRing(self):
        self.RingID=input("Enter RingID")
        self.Radius=input("Enter radius")
        self.AreaCal() # OR AreaCal(self)
    def ViewRing(self):
        print self.RingID
        print self.Radius
        print self.Area

 


Share

CSKC| Created: 12-Jan-2019 | Updated: 12-Jan-2019|CBSE12D-2017









Back