Skip to content

Instantly share code, notes, and snippets.

@hoangbui10111997
Last active August 15, 2019 03:48
Show Gist options
  • Save hoangbui10111997/fb4860baeacd1907fb823ebd3d74e58f to your computer and use it in GitHub Desktop.
Save hoangbui10111997/fb4860baeacd1907fb823ebd3d74e58f to your computer and use it in GitHub Desktop.
import datetime
import os
def main():
x = int(input('Number of deposit: '))
total = 0
info = list()
for x in range(0, x):
os.system('cls' if os.name=='nt' else 'clear')
money = float(input('Deposit: '))
rate = float(input('Rate: '))
date = input('Start date(dd-mm-yyyyy): ')
datecache = datetime.datetime.now()
datenow = datecache.strftime("%d-%m-%Y")
month = (int(datenow[(len(datenow) - 4):]) * 12 + int(datenow[(len(datenow) - 7):(len(datenow) - 5)])) - (int(date[(len(date) - 4):]) * 12 + int(date[(len(date) - 7):(len(date) - 5)]))
if int(datenow[0:2]) < int(date[0:2]):
month -= 1
interest = (((money * rate) / 100) / 12) * month
dict_info = {'Deposit': money,
'Rate': rate,
'Startdate': date,
'Period': month,
'Interest': interest,
'Total': money + interest
}
info.append(dict_info)
total += (money + interest)
os.system('cls' if os.name=='nt' else 'clear')
for x in range(0,len(info)):
print('Deposit: ' + str(info[x]['Deposit']))
print('Rate: ' + str(info[x]['Rate']) + '%')
print('Startdate: ' + str(info[x]['Startdate']))
print('Period: ' + str(info[x]['Period']) + ' month')
print('Interest: ' + str(info[x]['Interest']))
print('Total: ' + str(info[x]['Total']))
print('-------------------------------')
print("All total: " + str(total))
print("Today: " + datecache.strftime("%d-%m-%Y"))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment