diff --git a/Employee Class.ipynb b/Employee Class.ipynb index 3ee4690..81a020d 100644 --- a/Employee Class.ipynb +++ b/Employee Class.ipynb @@ -11,11 +11,19 @@ "text": [ "1.04\n", "1.04\n", - "1.04\n", - "1.1\n", - "1.1\n", - "1.1\n" + "Soumyadip\n", + "Hello\n" ] + }, + { + "data": { + "text/plain": [ + "'Soumyadip Chowdhury s.c@python.com 100000'" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -24,38 +32,26 @@ " no_empl=0;\n", " raise_amount=1.04\n", " \n", - " def __init__(self,f ,l ,p ):\n", - " self.first=f\n", - " self.last=l\n", - " self.email=f+\".\"+l+\"@python.com\"\n", - " self.pay=p\n", + " def __init__(self):\n", + " self.first=\"Soumyadip\"\n", + " self.last=\"Chowdhury\"\n", + " self.email=\"s.c@python.com\"\n", + " self.pay=100000\n", " Employee.no_empl=Employee.no_empl+1\n", " \n", " \n", " def print(self):\n", + " print(\"Hello\")\n", " return \"{} {} {} {}\".format(self.first,self.last,self.email,self.pay)\n", " \n", - " def apply_raise(self):\n", - " self.pay=int(self.pay* self.raise_amount)\n", - " ## Can print using class,self and obj name \n", - " \n", - " @classmethod\n", - " def set_raise_amt(cls,amount):\n", - " cls.raise_amount=amount\n", " \n", " \n", - "emp_1=Employee(\"Soumyadip\",\"Chowdhury\",900000)\n", - "emp_2=Employee(\"Soumyadip\",\"Chowdhury\",100000)\n", - "\n", + "emp_1=Employee()\n", "print(Employee.raise_amount)\n", "print(emp_1.raise_amount)\n", - "print(emp_2.raise_amount)\n", "\n", - "Employee.set_raise_amt(1.10)\n", - "\n", - "print(Employee.raise_amount)\n", - "print(emp_1.raise_amount)\n", - "print(emp_2.raise_amount)" + "print(emp_1.first)\n", + "emp_1.print()" ] }, { diff --git a/Employee Obj.ipynb b/Employee Obj.ipynb index aa868f4..5f46e8f 100644 --- a/Employee Obj.ipynb +++ b/Employee Obj.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -15,15 +15,15 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "<__main__.Employee object at 0x000001C215A66B48>\n", - "<__main__.Employee object at 0x000001C21469B348>\n" + "<__main__.Employee object at 0x000001D9F490C2C8>\n", + "<__main__.Employee object at 0x000001D9F490C308>\n" ] } ], @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -46,14 +46,14 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "<__main__.Employee object at 0x000001C215A66B48>\n", + "<__main__.Employee object at 0x000001D9F490C2C8>\n", "Soumyadip\n", "Chowdhury\n", "soumyadip.cmp@gmail.com\n", diff --git a/Employee Print Object.ipynb b/Employee Print Object.ipynb index cc4d874..400fe22 100644 --- a/Employee Print Object.ipynb +++ b/Employee Print Object.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 19, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -10,18 +10,8 @@ "output_type": "stream", "text": [ "Soumyadip Chowdhury Soumyadip.Chowdhury@python.com 900000\n", - "Soumyadip Chowdhury Soumyadip.Chowdhury@python.com 100000\n" - ] - }, - { - "ename": "TypeError", - "evalue": "print() missing 1 required positional argument: 'self'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 16\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 17\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEmployee\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 18\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEmployee\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mTypeError\u001b[0m: print() missing 1 required positional argument: 'self'" + "Bristi Biswas Bristi.Biswas@python.com 100000\n", + "True\n" ] } ], @@ -36,14 +26,14 @@ " \n", " def print(self):\n", " return \"{} {} {} {}\".format(self.first,self.last,self.email,self.pay)\n", - " \n", - " \n", + " \n", + "\n", "emp_1=Employee(\"Soumyadip\",\"Chowdhury\",900000)\n", - "emp_2=Employee(\"Soumyadip\",\"Chowdhury\",100000)\n", + "emp_2=Employee(\"Bristi\",\"Biswas\",100000)\n", "print(emp_1.print())\n", "print(emp_2.print())\n", - "print(Employee.print(emp_1))\n", - "print(Employee.print(emp_2))" + "\n", + "print(isinstance(emp_1,Employee))" ] } ], diff --git a/Employee isInstanse & isSubclass.ipynb b/Employee isInstanse & isSubclass.ipynb index 197f94f..72c7cc2 100644 --- a/Employee isInstanse & isSubclass.ipynb +++ b/Employee isInstanse & isSubclass.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 7, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -16,7 +16,7 @@ "True\n", "True\n", "True\n", - "True\n", + "(, )\n", "False\n" ] } diff --git a/README.md b/README.md index 869eeb8..2d75e1f 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# Object-Oriented-Programming-Using-Python \ No newline at end of file +# Object-Oriented-Programming-Using-Python +Python is a multi-paradigm programming language. Meaning, it supports different programming approach. One of the popular approach to solve a programming problem is by creating objects. This is known as Object-Oriented Programming (OOP).