import sys
def do(money, years, profit, add_money):
print("inputed money :", money, end=", ")
print("inputed years :", years, end=", ")
print("inputed profit :", profit)
result = money
for year in range(1, int(years)+1):
result += result * profit
print(f"After {year} year: {result}")
result += add_money
return result - add_money
if __name__ == "__main__":
param = {
'm': 0, # money
'y': 0, # years
'p': 0.0, # profit
'a': 0, # add_money
}
is_called_help = False
for arg in sys.argv[1:]:
if arg == 'help':
print("usage : python3 calculator.py m={invest cost} y={invest period} p={profit per year} a={add_money_per_year")
is_called_help = True
break
if '=' in arg:
key, value = arg.split('=')
param[key] = value
if not is_called_help:
print("total : ", do(money=int(param['m']), years=int(param['y']),
profit=float(param['p']), add_money=int(param['a']))
)