what is a class?
Class is a template for an object
Class should follow camel case notation
All classes in one file - when classes are short
One class per file - when classes are long
when to use a class?
Several functions with share state
More than one copy of the same state variables
To extend the behavior of an existing functionality
Do not use classes for simple things
Example:
class Calculator:
pi = 3.14
def add(self, num1, num2):
return num1 + num2
def sub(self, num1, num2):
return num1 - num2
References
https://docs.python.org/dev/tutorial/...
https://learnbatta.com/course/python/...
#python #python3 #class #object #learning #learnbatta
On this page of the site you can watch the video online python - classes objects with a duration of hours minute second in good quality, which was uploaded by the user Learnbatta 12 January 2024, share the link with friends and acquaintances, this video has already been watched 168 times on youtube and it was liked by 10 viewers. Enjoy your viewing!