In: Computer Science
name=input("Investment name:")
amount=int(input("Invested amount:"))
rate=float(input("Annual return rate:"))
years=float(input("No. of years:"))
final_amount=amount*((1+rate)**years)
print("An investment of","$",round(amount,2),"in",name,"today will
grow to $",round(final_amount,2),"after",int(years),"years.")
print("An investment of "+"$"+str(amount)+" in "+name+" today will
grow to $"+str(round(final_amount,2))+" after "+str(int(years))+"
years.")
C:\>py investment.py
Experiment with various values of the input variables when prompted, and try to correlate the outputs with the last two concatenation/print commands in the script file.
Also experiment with the commands in the script by removing the functions int, float, round, and str, and see what happens. show step by step answer using Jupyter.
name=input("Investment name:")
amount=int(input("Invested amount:"))
rate=float(input("Annual return rate:"))
years=float(input("No. of years:"))
final_amount=amount*((1+rate)**years)
print("An investment of","$",round(amount,2),"in",name,"today will
grow to $",round(final_amount,2),"after",int(years),"years.")
print("An investment of "+"$"+str(amount)+" in "+name+" today will
grow to $"+str(round(final_amount,2))+" after "+str(int(years))+"
years.")