The assignment is to write a class called data A Date object

The assignment is to write a class called data. A Date object is intented to represent a particuar date\'s month, day and year. It should be represented as an int.

-- write an appropriate __repr__ method.

python 2.7.13

Solution

PROGRAM CODE:

class data(object):
   def __init__(self, date, month, year):
       self.date = date
       self.month = month
       self.year = year
      
   def __repr__(self):
       return \'%s/%s/%s\' % (self.date, self.month, self.year)
      
today = data(24, 1, 2017)
print(today)

OUTPUT:

The assignment is to write a class called data. A Date object is intented to represent a particuar date\'s month, day and year. It should be represented as an i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site