File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 14
14
class Employee :
15
15
''' This is the version 1.0 of Employee class''' #doc string
16
16
#Defining constructor of class Employee
17
- #self refers to the current object (same like this in java)
17
+ #self refers to the current object (same like this in java programming )
18
18
#any variable defined with self is an instance variable in python
19
19
def __init__ (self ):
20
20
super ().__init__ ()
@@ -50,6 +50,6 @@ def display(self):
50
50
#Employee Salary: 100000
51
51
52
52
#Important Notes:
53
- #self is not a keyword or reserved word is python
53
+ #self is not a keyword or reserved word in python
54
54
#we can use any name instead of self like this
55
55
#The first parameter paased to any instance method is pointing to the current object
Original file line number Diff line number Diff line change
1
+ #Here we will import calculator module from the custom package
2
+
3
+ #If you see no myfirstpackage module found error make sure your project directory is
4
+ #on the class path
5
+ #hit this on command prompt with proper path of your project directory
6
+ #export PYTHONPATH="${PYTHONPATH}:/path/to/your/project"
7
+
8
+ from myfirstpackage import calculator as calc
9
+
10
+ print (calc .sum (2 ,3 ))
11
+
12
+ print (calc .mul (2 ,3 ))
13
+
Original file line number Diff line number Diff line change
1
+ #every package folder would have __init__.py file to declare it as a package
2
+ print ('Initializing myfirstpackage!' )
Original file line number Diff line number Diff line change
1
+ #This module will have calculator functionality.
2
+
3
+ def sum (x ,y ):
4
+ return x + y
5
+
6
+
7
+ def sub (x ,y ):
8
+ return x - y
9
+
10
+
11
+ def mul (x ,y ):
12
+ return x * y
13
+
14
+
15
+ def div (x ,y ):
16
+ return x / y
You can’t perform that action at this time.
0 commit comments