Skip to content

Commit 4eeeb74

Browse files
Update 2019-09-19-Python-Oop.md
1 parent 090c34d commit 4eeeb74

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

_posts/2019-09-19-Python-Oop.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tags:
1616
As we all know Python is Object Oriented Programming language. But you won't believe we are using Python OOP from our first program itself. For example if you try following snippet you will get what I am saying.
1717

1818
<pre class="line-numbers">
19-
<code class="python">
19+
<code class="language-python">
2020
x = 2
2121
print(type(x))
2222
</code>
@@ -32,15 +32,15 @@ It will give you following result: ```<class 'int'>```
3232
## How do we create simple class?
3333
Using class keyword we can create new class. The syntax of class is given below:
3434
<pre class="line-numbers">
35-
<code class="python">
35+
<code class="language-python">
3636
class class_name:
3737
method_definitions
3838
</code>
3939
</pre>
4040

4141
Let us create our own class,
4242
<pre class="line-numbers">
43-
<code class="python">
43+
<code class="language-python">
4444
class Employee:
4545
pass
4646
</code>
@@ -50,15 +50,15 @@ class Employee:
5050

5151
Let us create a new objects of our class Employee:
5252
<pre class="line-numbers">
53-
<code class="python">
53+
<code class="language-python">
5454
employee1 = Employee()
5555
employee2 = Employee()
5656
</code>
5757
</pre>
5858

5959
Let us check whether we are created instances of class Employee successfully:
6060
<pre class="line-numbers">
61-
<code class="python">
61+
<code class="language-python">
6262
print(type(employee1))
6363
</code>
6464
</pre>
@@ -68,7 +68,7 @@ This will give you something like ```<class '__main__.Employee'>```. Then it is
6868
Now it is the time to create instance variables. Instance variables are used for attach data to individual objects. Using these instance variable we can attach data field directly to at runtime. Instances are written outside class.
6969

7070
<pre class="line-numbers">
71-
<code class="python">
71+
<code class="language-python">
7272
employee1.firstName = 'Arun'
7373
employee1.lastName = 'Soman'
7474
employee1.email = employee1.firstName + employee1.lastName+'@company.com'
@@ -99,7 +99,7 @@ Python supports following types of methods
9999
We will discuss about all of the above methods in upcoming blog posts. Let us create a regular method by extending our previous program.
100100

101101
<pre class="line-numbers">
102-
<code class="python">
102+
<code class="language-python">
103103
class Employee:
104104
def fullName(firstName, lastName):
105105
return firstName + ' '+ lastName

0 commit comments

Comments
 (0)