What is a class?
This defines a set of attributes that will characterize any object that is instantiated from the class. Python is based on OOP’s concept i.e Object Oriented Programming which means you don’t have to write the same program for different devices. If you write a program for a mobile phone it can also be used for a laptop or desktop. To call a function form a class we can do <class name>.<function name>(parameters if there)
let me show you an example of a class
What is a function?
A function is always defined by the keyword ‘def’. Take the above example of a class where def addition is a function. There can be multiple functions in a class.For clear understanding think a python class as a regular classroom and function as a student in that classroom.Let you show you a simple calculator based on this understanding.
here calculator.multiplication is calling the function multiplication and the parameters in(3,5) are the values assigned to x and y respectively.
Try this program out in your IDLE with different values of x and y. Last but not the least there are two division symbols in python which are ‘/’ and ‘%’. the first one i.e called ‘by’ gives the quotient as the output answer and the second one called modulus gives remainder as the answer.
Once again thank you for reading and if you have any doubts feel free to contact me by commenting or emailing me