-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1_Firstopp.py
More file actions
28 lines (23 loc) · 816 Bytes
/
Copy path1_Firstopp.py
File metadata and controls
28 lines (23 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#C0d3 n0=x001
#made By GuND0Wn151
class Car:
#__init is constructor whihc instantiates an object
name=""
def __init__(self,x):
self.name=x
print("in init")
#methods in which can be declared
def horn(self):
print("Horn")
def noOfWheels(self):
print("car has 4 wheels")
#TO Use The class create a object of that class
#by default the python calls the __init__ function for creating the object
person=Car("Ram") #this calls the __init__ and the print statement in fucntions run
#TO use a object variable use objectName.variableName
#this does return a value whihc can be stored or printed
print(person.name)
#For calling methods or fucntions of the class use the object
#objectName.FUnctionName
person.horn()
person.noOfWheels()