-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path37_BankAccount.py
71 lines (53 loc) · 1.68 KB
/
37_BankAccount.py
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
# 37 - Bank Account
# Codédex
'''
class Student:
def __init__(self, name, year, enrolled, gpa):
self.name = name
self.year = year
self.enrolled = enrolled
self.gpa = gpa
def display_info(self):
print('The student ' + self.name + '\'s GPA is ' + str(self.gpa) + '!')
mitsuha = Student('宮水三葉', 11, False, 4.0)
taki = Student('立花瀧', 11, True, 3.8)
mitsuha.display_info()
taki.display_info()
# Output:
# The student 宮水三葉's GPA is 4.0!
# The student 立花瀧's GPA is 3.8!
#################
class Student:
def __init__(self, name, year, enrolled, gpa):
self.name = name
self.year = year
self.enrolled = enrolled
self.gpa = gpa
def display_info(self):
print('The student ' + self.name + '\'s is ' + str(self.gpa) + '!')
def graduation(self):
if self.enrolled and self.gpa > 2.5 and self.year == 12:
print(self.name + ' will be able to graduate this year!')
'''
# Write code below 💖
class BankAccount:
def __init__(self, first_name, last_name, account_id, account_type, pin, balance):
self.first_name = first_name
self.last_name = last_name
self.account_id = account_id
self.account_type = account_type
self.pin = pin
self.balance = balance
def deposit(self, amount):
self.balance = self.balance + amount
return self.balance
def withdraw(self, amount):
self.balance = self.balance - amount
return self.balance
def display_balance(self):
print(f"${self.balance}")
savings = BankAccount('Bella', 'the Cat', 123456, 'Savings', 56789, 300)
savings.deposit(96)
savings.display_balance() # Output: $396
savings.withdraw(25)
savings.display_balance() # Output: $371