Computer Science, asked by fanofjd19, 8 months ago

write a class with two private class variables and print the sum using a method
(python)

Answers

Answered by ammumisty
4

Answer:

A function performs an action using some set of input parameters. Not all functions are applicable to all kinds of data. Classes are a way of grouping together related data and functions which act upon that data.

A class is a kind of data type, just like a string, integer or list. When we create an object of that data type, we call it an instance of a class.

def age(self):

if hasattr(self, "_age"):

return self._age

today = datetime.date.today()

age = today.year - self.birthdate.year

if today < datetime.date(today.year, self.birthdate.month, self.birthdate.day):

age -= 1

self._age = age

return age

Similar questions