Installation of jupyter via anaconda by the following link
https://www.anaconda.com/products/individual
Three important terms in OOPs
from IPython import display
display.Image("01.png")
class Student(): # class--->> name of class is Student
def __init__(self): # actions/behaviour/method --- but this special type of method known as constructor
self.name = "zain" # properties/instance variable/attributes --->> name
self.age = 19 # properties/instance variable/attributes --->> age
self.marks = 95 # properties/instance variable/attributes --->> marks
def display(self): # actions/behaviour/method/instance method
print("Hello my name: ",self.name)
print("My age: ",self.age)
print("My marks: ",self.marks)
s=Student() # s is the reference variable and s=Student() is the object
print(s.name) # recall the "name" attribute
print(s.age) # recall the "age" attribute
print(s.marks) # recall the marks attribute
print("=========================================")
s.display() # recall the 2nd method i.e display
#NOTE: This is not recommended because we used hard coding.
class Student(): # class--->> name of class is Student
def __init__(self,name,age,marks): # actions/behaviour/method --- but this special type of method known as constructor
self.name = name # properties/instance variable/attributes --->> name
self.age = age # properties/instance variable/attributes --->> age
self.marks = marks # properties/instance variable/attributes --->> marks
def display(self): # actions/behaviour/method/instance method
print("Hello my name: ",self.name)
print("My age: ",self.age)
print("My marks: ",self.marks)
s1=Student("Zain",19,95) # s1 is the reference variable and s1=Student() is the 1st object
print(s1.name) # recall the "name" attribute
print(s1.age) # recall the "age" attribute
print(s1.marks) # recall the marks attribute
print("=========================================")
s1.display() # recall the 2nd method i.e display
print("\n")
s2=Student("Mike",21,96) # s2 is the reference variable and s2=Student() is the 2nd object
print(s2.name) # recall the "name" attribute
print(s2.age) # recall the "age" attribute
print(s2.marks) # recall the marks attribute
print("=========================================")
s2.display() # recall the 2nd method i.e display
class Student(): # class--->> name of class is Student
def __init__(self,name,age,marks): # actions/behaviour/method --- but this special type of method known as constructor
self.name = name # properties/instance variable/attributes --->> name
self.age = age # properties/instance variable/attributes --->> age
self.marks = marks # properties/instance variable/attributes --->> marks
def display(self): # actions/behaviour/method/instance method
print("Hello my name:{},My marks:{}".format(self.name,self.marks))
s1=Student("Zain",19,95) # s1 is the reference variable and s1=Student() is the 1st object
s1.display() # recall the 2nd method i.e display
print("\n")
s2=Student("Mike",21,96) # s2 is the reference variable and s2=Student() is the 2nd object
s2.display() # recall the 2nd method i.e display
class Student(): # class--->> name of class is Student
def __init__(self,name,age,marks): # actions/behaviour/method --- but this special type of method known as constructor
self.name = name # properties/instance variable/attributes --->> name
self.age = age # properties/instance variable/attributes --->> age
self.marks = marks # properties/instance variable/attributes --->> marks
def display(self): # actions/behaviour/method/instance method
print("Hello my name:{}\nMy marks:{}".format(self.name,self.marks))
s1=Student("Zain",19,95) # s1 is the reference variable and s1=Student() is the 1st object
s1.display() # recall the 2nd method i.e display
print("\n")
s2=Student("Mike",21,96) # s2 is the reference variable and s2=Student() is the 2nd object
s2.display() # recall the 2nd method i.e display
class Student(): # class--->> name of class is Student
def __init__(self,name,age,marks): # actions/behaviour/method --- but this special type of method known as constructor
self.name = name # properties/instance variable/attributes --->> name
self.age = age # properties/instance variable/attributes --->> age
self.marks = marks # properties/instance variable/attributes --->> marks
def display(self): # actions/behaviour/method/instance method
print("Name:{}\nAge:{}\nMarks:{}".format(self.name,self.age,self.marks))
s1=Student("Zain",19,95) # s1 is the reference variable and s1=Student() is the 1st object
s1.display() # recall the 2nd method i.e display
print("\n")
s2=Student("Mike",21,96) # s2 is the reference variable and s2=Student() is the 2nd object
s2.display() # recall the 2nd method i.e display
No comments:
Post a Comment