-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructor.py
More file actions
78 lines (56 loc) · 1.77 KB
/
Copy pathconstructor.py
File metadata and controls
78 lines (56 loc) · 1.77 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# class sharmavishnu:
# def greet(self):
# print("This is function")
# def greet(self):
# print("This is 2nd function")
# indrapuri = sharmavishnu()
# sharmavishnu.greet()
### constructor -->>represent by __init__(Dunder Methods)
##Constructor sabse pahle execute hone wale functions hai doesn't matter inke upar ya neeche koi function present hai
# class sharmavishnu:
# def __init__(self):
# print("This is constructor function")
# def __init__(self):
# print("This is constructor function")
# def menu(self):
# print('paneer kulche')
# obj = sharmavishnu()
# obj.menu()
####
# class sharmavishnu:
# def __init__(self,name,age):
# self.name = name ##Instances attributes
# self.age = age
# print("This is constructor function")
# def menu(self):
# print(self.name)
# print(self.age)
# obj = sharmavishnu("Deepak" , 21)
# obj.menu()
##make a class which will take 2 numbers as input create
# 1.2instance object
#2. create a function which will print greates among them
class student:
def __init__(self,a,b):
self.a = a
self.b = b
print("this is student class")
def greater(self):
if self.a > self.b:
print(self.a, "is greater")
else:
print(self.b, "is greater")
obj = student(10,20)
obj.greater()
# class Laxit:
# def _init_(self):
# print("This is the Laxit class")
# def greet(self,a,b):
# print(f"The sum of {a} and {b} is {a+b}")
# def _init_(self):
# print("This is another constructor function")
# def greet(self,name):
# self.name = name #Instance Attribute
# print(f'hello {self.name}')
# obj = Laxit()
# obj.greet(":Laxit")