forked from kal179/Beginners-Python-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
piggyBank.py
57 lines (51 loc) · 1.57 KB
/
piggyBank.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
# piggy bank
# pre code
money = 0
# function to add money to current amount
def addMoney():
print(" ")
userAdd = float(raw_input("Add money : "))
print(" ")
money = money + userAdd
print("After adding current Money you have is " + str(money) + " rupees")
# function to withdraw money from current amount
def withdrawMoney():
print(" ")
userWithdraw = float(raw_input("Add money : "))
print(" ")
money = money + userWithdraw
print("After adding current Money you have is " + str(money) + " rupees")
# function to display current amount
def currentMoney():
print(" ")
current = "Current money you have is " + str(money) + " rupees"
# main code
print(" ")
print("--------------------Start-------------------")
while True:
print(" ")
user = raw_input("Start or End : ")
if user.strip() == "Start":
controlPiggy = raw_input("Add Withdraw or Check : ")
if controlPiggy.strip() == "Add":
print(addMoney())
continue
elif controlPiggy.strip() == "Withdraw":
print(withdrawMoney())
continue
elif controlPiggy.strip() == "Check":
print(currentMoney())
continue
else :
print(" ")
print("Invalid Input.Try again")
continue
elif user.strip() == "End" :
print(" ")
print("------------Program Ended-----------")
print(" ")
break
else :
print(" ")
print("Invalid Input. Try again")
continue