-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatm.py
193 lines (163 loc) · 6.55 KB
/
atm.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# -*- coding: utf-8 -*-
"""ATM.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1SzYpoIm2sXERHpq-pXJzVC5cNplIhB7x
ATM Simulator Assignment is written in Python. The Assignment file contains a python
script (atm.py). This is a simple console-based system which is very easy to use. Talking
about the system, it contains various functions which include View Balance, Withdrawing,
Depositing amount, and changing the pin. Here, at first, the user has to enter an existing
username, when the username matches the system proceed toward the next procedure i.e
asking for a password/pin number. When a user passes all these sign-in procedures,
he/she can use all those features. It is too easy to use, he/she can check their respective
account statements, Deposit, and Withdrawing as well.
While the user forgot the password on login you have to create a forgot password
functionality.
And forgot password on based on stored email address. If the user type coreect email then
you have to give a prompt for new password.
While depositing or withdrawing an amount, he/she just has to enter the amount then the
system calculates the total remaining balance of the respective account and displays to the
user. And the user can view all these transactions from the account statement. In this ATM
Simulator, the user can also change the password/pin number. For this, the user has to
enter the New pin code and then confirm it in order to change the pin code. This simple
console-based ATM simulator provides the simple account balance management of a
respective account. It contains all the essential features. There is no database connection
or neither any external text nor other files used in this mini Assignment to save the user’s
data. Everything is set inside the source code whether its password/pin code or the
amount.
Functality:
1. Login
2. Sign Up
3. Exit
4. Withdrawl
5. Deposit
6. View Balance
7. Password Change
8. Forgot password
ToDOs
"""
# DONE: The Assignment file contains a python script (atm.py).
# DONE: The system contains various functions which include View Balance, Withdrawing, Depositing amount, and changing the pin.
# DONE: The user has to enter an existing username,
# DONE: when the username matches the system proceed toward the next procedure i.e asking for a password/pin number.
# DONE: While the user forgot the password on login you have to create a forgot password functionality.
# DONE: And forgot password on based on stored email address. If the user type correct email then you have to give a prompt for new password.
# DONE: When a user passes all these sign-in procedures,
# DONE: he/she can use all those features: View Balance, Withdrawing, Depositing amount, and changing the pin.
# DONE: he/she can check their respective account statements, Deposit, and Withdrawing as well.
# DONE: While depositing or withdrawing an amount, he/she just has to enter the amount then the system calculates the total remaining balance of the respective account and displays to the user.
# DONE: And the user can view all these transactions from the account statement.
# DONE: the user can also change the password/pin number. For this, the user has to enter the New pin code and then confirm it in order to change the pin code.
# DONE: This simple console-based ATM simulator provides the simple account balance management of a respective account.
database = {
'username_1':{
'name' : 'user 1',
'age': 24,
'email': '[email protected]',
'password': 'user1',
'balance' : 1000
},
'username_2':{
'name' : 'user 2',
'age': 24,
'email': '[email protected]',
'password': 'user2',
'balance' : 1000
},
'username_3':{
'name' : 'user 3',
'age': 24,
'email': '[email protected]',
'password': 'user3',
'balance' : 1000
},'username_4':{
'name' : 'user 4',
'age': 24,
'email': '[email protected]',
'password': 'user4',
'balance' : 1000
}
}
def login(usern, password):
while usern not in database or database[usern]['password'] != password:
usern = input('Please enter your correct username: ')
password =input('please enter your corresponding password: ')
forgot = input('Forgot password? Y/N: ')
if forgot == 'Y' or forgot == 'y':
email = input('Enter your email: ')
passwordChange(usern, email)
print('Welcome!')
return usern
def signUp():
username = 'username_1'
while username in database:
username = input('Choose username that is not taken: ')
name = input('Enter your name: ')
age = int(input('Enter your age: '))
email = input('Enter your email: ')
password = input('Choose a strong password: ')
database[username] = {
'name' : name,
'age' : age,
'email' : email,
'password' : password,
'balance' : 1000
}
print('Congratulations! New account created.')
def withdrawal(user):
amount = int(input('Enter amount to withdraw'))
if (amount > database[user]['balance']):
print("Sorry, currently you don't have sufficient balance.")
else:
database[user]['balance'] = database[user]['balance'] - amount
print("Transaction successful!")
def deposit(user):
amount = int(input('Enter amount to deposit'))
database[user]['balance'] = database[user]['balance'] + amount
print("Transaction successful!")
def viewBalance(user):
print('Your balance is {} INR'.format(database[user]['balance']))
def passwordChange(user, email):
while email != database[user]['email']:
email = input('Enter your correct email ID:')
database[user]['password'] = input('Choose your new password: ')
print('Password changed! Now login please!')
def option():
input(
'''
Choose the following options:
0. Exit
1. Deposit
2. Withdraw
3. View Balance
4. Change Password
'''
)
def main():
input('''
Choose one of the options:
1. Login
2. Sign Up
0. Exit
''')
num = int(main())
while num != 0:
if num == 1:
username = input('Enter username: ')
password = input('Enter Password: ')
user = login(username, password)
choice = int(option())
while choice != 0:
if choice == 1:
deposit(user)
elif choice == 2:
withdrawal(user)
elif choice == 3:
viewBalance(user)
elif choice == 4:
email = input('Enter you email: ')
passwordChange(user, email)
choice = int(option())
elif num == 2:
signUp()
num = int(main())