Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/bank.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/bank1.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/client.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/client1.cpython-38.pyc
Binary file not shown.
22 changes: 22 additions & 0 deletions bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import time
class Bank:
__clients=[]
def __init__(self,name):
self.name=name

def add_clients(self,client):
self.__clients.append(client)

def authentication(self,name,account_number):
for i in range(len(self.__clients)):
if name == self.__clients[i].name and account_number == self.__clients[i].account_number:
time.sleep(1)
print("Authentication successful!")
return self.__clients[i]
print('''
Authentication failed!
Reason: account not found.
''')

def getclients(self):
return self.__clients
25 changes: 25 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import random
random_list=list(set(random.randint(10000,99999) for i in range(9999)))
class Client:
i=0
def __init__(self,name,total_amount):
self.name=name
self.total_amount=total_amount
self.account_number=random_list[Client.i]
Client.i+=1
def withdrawn(self,amount):
if self.total_amount>=amount:
self.total_amount-=amount
print("The sum of {} has been withdrawn from your account balance.".format(amount))
self.current_balance()
return self.total_amount
else:
print("Your current account balance is not enough.")
def deposit(self,amount):
self.total_amount+=amount
print("The sum of {} has been added to your account balance.".format(amount))
self.current_balance()
return self.total_amount

def current_balance(self):
print ("Your current account balance is: {}".format(self.total_amount))
44 changes: 44 additions & 0 deletions hackerrank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#1. sWAP cASE: https://www.hackerrank.com/challenges/swap-case/problem
def swap_case(s):
a=""
for i in s:
if i.isupper():
a+=i.lower()
elif i.islower():
a+=i.upper()
else:
a+=i
return a


if __name__ == '__main__':
s = input()
result = swap_case(s)
print(result)

# 2. String Split and Join: https://www.hackerrank.com/challenges/python-string-split-and-join/problem
def split_and_join(line):
return '-'.join(line.split(' '))
if __name__ == '__main__':
line = input()
result = split_and_join(line)
print(result)
# 3. Mutations: https://www.hackerrank.com/challenges/python-mutations/problem
def mutate_string(string, position, character):
return string[:position]+character+string[position+1:]

if __name__ == '__main__':
s = input()
i, c = input().split()
s_new = mutate_string(s, int(i), c)
print(s_new)
#4. Text Wrap: https://www.hackerrank.com/challenges/text-wrap/problem
import textwrap
def wrap(string, max_width):
return '\n'.join([string[i:i+max_width] for i in range(0,len(string),max_width)])


if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
57 changes: 57 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from client import Client
from bank import Bank
import time

b1=Bank(input('Name of Bank: '))

available=True
while available:
print("Welcome to {}".format(b1.name))
print("""Choose an option:
1. Open new bank account
2. Open existing bank account
3. Exit
""")
choice=int(input("1,2,3: "))
if choice==3:
available = False
elif choice==1:
print("To create an account, please fill in the information below.")
name_=input("Name: ")
t_amount=int(input("Total amount: "))
client1=Client(name_, t_amount)
b1.add_clients(client1)
time.sleep(1)
print("Account created successfully! Your account number is: {}".format(client1.account_number))
elif choice==2:
print("To access your account, please enter your credentials below.")
account_number=int(input("Account number: "))
name=input("Name: ")
client_authentication=b1.authentication(name,account_number)
if client_authentication:
authorized = True
print("Bank account is opening...")
time.sleep(1)
print('Welcome {}'.format(name))
while authorized:
print("""Choose an option:
1. Withdraw
2. Deposit
3. Balance
4. Exit""")
choice1=int(input("Choice: "))
if choice1==1:
w_amount = int(input("Withdraw amount:"))
client_authentication.withdrawn(w_amount)
elif choice1==2:
d_amount = int(input("Deposit amount:"))
client_authentication.deposit(d_amount)
elif choice1==3:
client_authentication.current_balance()
elif choice1==4:
authorized=False

else:
time.sleep(1)
print('Authentication failed! \nReason: account is not found')

Binary file added q1.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added q2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added q3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.