Consider things in a real-world, e.g., schools entered, countries visited, companies worked, etc.
Take multiple elements and some relations among the elements in the real-world.
Group the elements into a few classes, so that each element can fall in a class.
Make sure that a class is defined over the features on those member elements.
In addition to the structural definition of a class, there may be behavioral definitions.
Behavioral definitions can be the methods of a class, and they are executed on an element(s).
Write a Python program to define the class called "Conversion".
This class has one feature, called inNum. Note that this number can be a temperature or
a mass, etc. This variable of Conversion will have a value when an object is constructed (or
init_ialized) as follows:
def __init__ (self, inNum):
self.inNum = inNum
This init() method usually appears first in the body of its class. After the init() method,
as many behavioral methods as needed can be defined.
This class has four methods
c2f(), which takes a number (read inNum) in Celsius and prints another number (save into outNum) in Fahrenheit
f2c(), which takes a number (read inNum) in Fahrenheit and prints another number (save into outNum) in Fahrenheit.
kg2lb(), which takes a number (read inNum) in kb and prints another number (save into outNum) in lb.
lb2kg(), which takes a number (read inNum) in lb and prints another number (save into outNum) in kg.
Multiple class members can be constructed.
c1 = Conversion(67)
c2 = Conversion(159)
c3 = Conversion(24)
more
Call the above functions as follows:
c1.c2f()
c2.f2c()
c2.c2f()
c2.lb2kg()
c3.kg2lb()
c3.f2c()
more
Note that inNum is loaded when an object is constructed and so
the __init()__ method is executed,
and outNum is loaded when a method is invoked.