+ 1
How do we solve this?
Exponentiation is the raising of one number to the power of another. This operation is performed using two asterisks **. Let's use exponentiation to solve a known problem. You are offered a choice of either $1.000.000 or $0.01 (one penny) doubled every day for 30 days (the resulting amount is doubled every day). Task: Write a program to calculate the amount that will result from the doubling to understand which choice results in a larger amount. Hint: Let's see how exponentiation can be useful to perform the calculation. For example, if we want to calculate how much money we will have on the 5th day, we can use this expression: 0.01*(2**5) = 0.32 dollars (multiply the penny by 2 raised to the power of 5).
4 Answers
+ 1
You already have the formula for five days. Adjust it for 30 days and compare the result to 1000000.
+ 1
print(0.01*(2**30))
+ 1
Thanks
+ 1
'''Enter the offer number from the options'''
print("Please, select your offer choice")
print("1. $1.000.000")
print("2. $0.01")
print(">>")
choice=int(input())
'''Enter the day number of the month to calculate the amount'''
print("Enter the day (Ex: 5): ")
print(">>")
day=int(input())
if choice==1:
print(1000000*(2**day))
else:
print(0.01*(2**day))