-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask3.py
129 lines (101 loc) · 3.61 KB
/
task3.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
from datetime import date
from random import randint
def greetings(msg):
print(msg)
def register():
print('Register an Account')
first_name = input('Enter your first name: ')
last_name = input('Enter your last name: ')
username = input('Enter your username: ')
email = input('Enter your email address: ')
while True:
password = input('Enter the password you wanna use: ')
password2 = input('Confirm your password: ')
if password == password2:
break
else:
print('The password you entered doesnt match, try again')
account_number = randint(1000000000, 3000000000)
print(
f'''
Congrats user created succesfully,
your data is saved and safe.
Account number generated succesfully {account_number}
'''
)
data = {
'first_name': first_name,
'last_name': last_name,
'username': username,
'email': email,
'password': password,
'account_number': account_number
}
return data
def login():
print('Login to the system')
username = input('Enter you username: ')
password = input('Enter your password: ')
data = {
'username': username,
'password': password
}
return data
def do_bankings(username):
today = date.today()
print(f'Welcome {username}')
print(today.strftime('%B %d, %Y'))
print('1. Withdrawal')
print('2. Cash deposit')
print('3. Complaint')
while True:
try:
selected_option = int(input('Please select an option from the above(Must be a number): '))
except ValueError:
print('invalid input, try again')
else:
break
if selected_option == 1:
while True:
try:
withrawal_amount = int(input('How much would you like to withdraw? '))
except ValueError:
print('Invalid input, try again')
else:
break
print(f'£{withrawal_amount} cash succesfully withdrawn')
print('Take your cash!')
elif selected_option == 2:
current_balance = 0
while True:
try:
deposit_amount = float(input('How much would you like to deposit? '))
except ValueError:
print('Invalid input, try again')
else:
break
current_balance += deposit_amount
print('Cash deposited successfully')
print(f'You current balance is: £{current_balance}')
elif selected_option == 3:
complaint = input('What issue will you like to report? ')
print(f'Dear {username}, your report "{complaint}" is under review')
print('Thank you for contacting us')
def main():
greetings('Welcome')
print('Register an account to login to the system')
# This line execute the function and return sign up info, which is save in the saved_login_data variable
saved_login_data = register()
# Get the user username from the saved sign up data
username = saved_login_data['username']
# Get the user password from the saved sign up data
password = saved_login_data['password']
while True:
login_in_info = login()
if login_in_info['username'] == username and login_in_info['password'] == password:
print('login succesfully')
do_bankings(username)
break
else:
print('Incorrect username or password, Try again')
main()