Skip to content

Commit e5a0c5b

Browse files
authored
Merge branch 'main' into kacey-lab09-quotes-api
2 parents 23d0c4f + 99009fb commit e5a0c5b

File tree

4 files changed

+75
-12
lines changed

4 files changed

+75
-12
lines changed

code/kaceyb/python/lab10/lab_10.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
class ATM:
2+
def __init__(self):
3+
self.balance = 0
4+
self.transactions = []
5+
6+
def check_balance(self):
7+
return round(self.balance, 2)
8+
9+
def deposit(self, amount):
10+
self.balance = self.balance + amount
11+
self.transactions.append(f'user deposited ${amount}')
12+
return self.balance
13+
14+
def withdraw(self, amount):
15+
self.balance = self.balance - amount
16+
self.transactions.append(f'user withdrew ${amount}')
17+
return self.balance
18+
19+
def check_withdrawal(self, amount):
20+
if amount > self.balance:
21+
return False
22+
return True
23+
24+
def calc_interest(self):
25+
calc_interest = (self.balance * .1) / 100
26+
return round(calc_interest, 2)
27+
28+
def print_transactions(self):
29+
for transaction in self.transactions:
30+
print(transaction)
31+
32+
33+
34+
35+
36+
37+
38+
atm = ATM() # create an instance of our class
39+
print('Welcome to the ATM')
40+
while True:
41+
command = input('Enter a command: ')
42+
if command == 'balance':
43+
balance = atm.check_balance() # call the check_balance() method
44+
print(f'Your balance is ${balance}')
45+
elif command == 'deposit':
46+
amount = float(input('How much would you like to deposit? '))
47+
atm.deposit(amount) # call the deposit(amount) method
48+
print(f'Deposited ${amount}')
49+
elif command == 'withdraw':
50+
amount = float(input('How much would you like '))
51+
if atm.check_withdrawal(amount): # call the check_withdrawal(amount) method
52+
atm.withdraw(amount) # call the withdraw(amount) method
53+
print(f'Withdrew ${amount}')
54+
else:
55+
print('Insufficient funds')
56+
elif command == 'interest':
57+
amount = atm.calc_interest() # call the calc_interest() method
58+
atm.deposit(amount)
59+
print(f'Accumulated ${amount} in interest')
60+
elif command == 'transactions':
61+
atm.print_transactions()
62+
elif command == 'help':
63+
print('Available commands:')
64+
print('balance - get the current balance')
65+
print('deposit - deposit money')
66+
print('withdraw - withdraw money')
67+
print('interest - accumulate interest')
68+
print('transactions - list of all transactions')
69+
print('exit - exit the program')
70+
71+
elif command == 'exit':
72+
break
73+
else:
74+
print('Command not recognized')

code/kaceyb/python/notes/lesson06/mini_capstone.py

Whitespace-only changes.

code/kaceyb/python/notes/lesson06/notes.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# with open('example.txt', 'a') as file:
22
# text = file.write('\nMORE TEXT')
3-
# print(text)
3+
# print(text)
44

55
# file = open('example2.txt', 'w')
66
# text = file.write('Legacy Method')
@@ -13,8 +13,6 @@
1313
# colors = file.read().split()
1414
# print(colors)
1515

16-
17-
1816
# colors = file.read().split()
1917
# print(colors)
2018

@@ -55,7 +53,6 @@
5553
# print(entry)
5654
# found_entry = True
5755

58-
5956
# if not found_entry:
6057
# print('Contact not found')
6158
# name = input('Enter new contact name: ')
@@ -67,15 +64,12 @@
6764
# with open('phonebook2.txt', 'w') as file2:
6865
# file2.write('\n'.join(phone_book))
6966

70-
71-
7267
# phone_book.append(name + " " + phone_number)
7368

7469
# phone_book.sort()
7570
# with open('phonebook2.txt', 'w') as file2:
7671
# file2.write('\n'.join(phone_book))
7772

78-
7973
# print(type(phone_book))
8074
# print(phone_book)
8175
# def Convert(lst):
@@ -88,6 +82,3 @@
8882
# color = Convert(color)
8983

9084
# print(color)
91-
92-
# print(color)
93-

code/kaceyb/python/notes/lesson06/notes2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
# for i in range(len(categories)):
2929
# print(i, categories[i])
30-
31-
3230

3331
# for i in range(len(categories)):
3432
# print(i, categories[i])

0 commit comments

Comments
 (0)