forked from bradtraversy/python_sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.py
More file actions
30 lines (24 loc) · 898 Bytes
/
Copy pathclasses.py
File metadata and controls
30 lines (24 loc) · 898 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
29
30
# A class is like a blueprint for creating objects. An object has properties and methods(functions) associated with it. Almost everything in Python is an object
class User:
def __init__(self, name, email, age):
super().__init__()
self.name = name
self.email = email
self.age = age
def greeting(self):
print(f'Hello {self.name}')
class Customer(User):
def __init__(self, name, email, age):
User.__init__(self, name, email, age)
self.name = name
self.email = email
self.age = age
self.balance = 0
def setBalance(self, balance):
print(f'Previos Balance was {self.balance}')
self.balance = balance
print(f'New Balance updated now !')
print(f'New Balance is {self.balance}')
nisuga = Customer('Nisuga', 'nisujdev@gmail.com', 23)
nisuga.greeting()
nisuga.setBalance(500)