High Level Programming languages three types: 1) Structured : C, C++, Python 2) Object Based : VB Script 3) Object Oriented : C++, Python and Java OOPs Concepts: ============= Object Oriented Programming System 1) Class 2) Object 3) Method 4) Constructors 5) Destructors 6) Encapsulation 7) Inheritance 8) Polymorphism 9) Overloading 10) Overriding 11) Abstraction etc. Class in Python: ================ Keyword: class collection of attributes and behaviors. Attributes ==> Data Behaviors ==> Methods Syntax: class class-name: code is for the class implementation attributes methods Class ==> Blueprint no memory is required. Object: ======= ==> physical entity which we can use to access the data (members of the class). create object: ============== object-name = class-name() To access the members of the class: object-name.member-name # class with attributes # the data or method in the class ==> member # can define with primitive types and also with collection type class classWithPrimitives: a = 121 b = 123.234e7 c = 123-234j d = True e = "Python" # print(a) obj = classWithPrimitives print(obj.a);print(obj.b);print(obj.c);print(obj.d);print(obj.e) ====================================== # Class with collection attributes class classWithAttributes: ld = [1,2,3,4,5] td = 1,3,5,7,9 sd = "Python" sed = {10,20,30,40,50} dd = {'a' : 11, 'b' : 111, 'c' : 1221} obj = classWithAttributes() print(obj.ld) print(obj.td) print(obj.sd) print(obj.sed) print(obj.dd) obj.ld.append(100) print(obj.ld) ===================================== How to define the multiple objects for one class: ================================================= # Class with collection attributes class classWithAttributes: ld = [1,2,3,4,5] td = 1,3,5,7,9 sd = "Python" sed = {10,20,30,40,50} dd = {'a' : 11, 'b' : 111, 'c' : 1221} obj = classWithAttributes() obj1 = classWithAttributes() # obj2,obj3 = classWithAttributes() obj2 = obj1 obj3 = obj print(obj.ld) print(obj.td) print(obj.sd) print(obj.sed) print(obj.dd) obj.ld.append(100) print(obj.ld) print(obj1.sed) print(obj2.sd) ======================================= Class with methods: =================== functions Vs Methods: ===================== the named block in outside the class ==> function the named block within the class ==> method to access the function, we cannot require the object. But to access a method, we need an object. self: ===== ==> is a keyword, which we can use to specify the method definition is belonging to the specific class. ==> self is acts as parameter without value assignment for the methods. # Class with methods as members class classWithMembers: def met1(self): print("Hi All.") def met2(self,name): print("Hello {},Good Evening.".format(name)) def met3(self,a,b): return a+b obj = classWithMembers() # obj.met1('name') obj.met1() obj.met2("Xyz") # print(obj.met3(100,200,250)) x = obj.met3(123,345) print(x)