Python Bank System
## Python3.x Python Simple Banking System
[ Python3 Examples](#)
The following example is for learning Python banking system operations:
## Example
means =[0,0,0]
loan =0
rate =0
pay =0
investment =0
annual_rate =0
# Calculate expected return on fixed investment
# The formula for fixed investment return is: M=a(1+x)[-1+(1+x)^n]/x;
# Where M represents expected return, a represents the fixed investment amount per period, x represents the return rate, and n represents the number of investment periods.
# Assuming the user invests 300 yuan monthly, which is 3600 yuan per year, with an annual return rate of 15%,
# with an investment period of 35 years, the return can be calculated as 3600(1+15%)[-1+(1+15%)^35]/15%=3648044 yuan.
def fixed_investment(inv, a_rate, y):
global means
inv =12 * inv
a_rate = a_rate / 100
if a_rate ==0:
expected =0
else:
expected = inv * (1 + a_rate) * (pow((1 + a_rate), y) - 1) / a_rate
print("Expected income from fixed investment: %.2f" % expected)
means= expected
return expected
def balance():
total =0
for i in means:
total += i
print("Your total assets are: %.2f" % total)
print("Your asset details:n")
print("Savings: %.2f" % means)
print("Financial management: %.2f" % means)
print("Debt: %.2f" % means)
def saving(amount):
global means
if amount <0:
print("Deposit amount cannot be less than 0!")
else:
means += amount
print("Deposited: %.2f yuan" % amount)
print("Current balance: %.2f yuan" % means)
def draw_money(drawing):
global means
if drawing means:
print("Withdrawal amount cannot exceed the balance!")
else:
means -= drawing
print("Withdrawn: %.2f yuan" % drawing)
print("Current balance: %.2f yuan" % means)
def loans(loan, rate, pay, years):
global means
if pay 0:
loan -= pay
loan *=(1 + rate)
count +=1
print("The loan will be fully repaid after %d years." % count)
else:
for _ in range(years):
loan -= pay
if loan ==0:
break
else:
loan *=(1 + rate)
print("Your current debt is: %.2f" % loan)
# means = loan
return loan
# Future financial status
def future(years):
income = fixed_investment(investment, annual_rate, years)
debt = loans(loan, rate, pay, years)
captial = means + income - debt
print("Your total assets in year %i are: %.3f" % (years, captial))
def init():
print()
print('''The following services are available:
1. Query Assets
2. Deposit
3. Withdraw
4.
YouTip