Skip to content

Commit

Permalink
class variable and instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Mar 27, 2019
1 parent e804e0a commit d76e79d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DataStructure/list_search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# list search using in and ternary operator
# made by : rakesh kumar
# made by : rakesh kumar sharma

a=[1,2,3,4,5,6,7,8,9]
print( 5 in a and '5 is available in list ' or 'not found')
3 changes: 3 additions & 0 deletions classes/class1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Example of class variable


class student():
name = "rakesh"
website ="binarynote.com"
Expand Down
5 changes: 5 additions & 0 deletions classes/class2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# program to show the use of class variable and instance variable
# made by : rakesh kumar
# last compiled on : 27/03/2019


class student():
name = "rakesh"
website ="binarynote.com"
Expand Down
27 changes: 11 additions & 16 deletions classes/classConstructor.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
class student():
name=""
website=""
expertise=""

def __init__(self):
self.name ="swarnima"
self.website = "http://www.swarnima.com"
self.expertise ="Django Specialist"

def showData(self):
print("Name : ",self.name)
print("website : ", self.website)
print("Expertise :", self.expertise,"\n")
class student:
def __init__(self,name,website,expertise):
self.name = name
self.website = website
self.expertise = expertise

def showdata(self):
return 'Name : {} \nWebsite: {} \nExpertise :{}'.format(self.name,self.website,self.expertise)
#object creation
#

s1 = student() #calling constructor
s1.showData()
s1 = student('rakehs','https://bianrynote.com','Django Specilist') #calling constructor
print(s1.showdata())

#calling function using class itself and passing object as its parameter
print(student.showdata(s1))

0 comments on commit d76e79d

Please sign in to comment.