0
What is the problem in the code
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. """"" v = 0.01 *(2**30) r = 1*(2**30) if v >= r: print(v) else: print(r) """"" When i run it the output is 1073741828 but it shows as 10737418.28 but how it is possible. Am i missing something please explain.
12 Answers
+ 2
where's your code tho? we don't see what you're thinking inside the brain.
+ 2
You need calculate only 1 cent doubled every day during the 30 days and print result, read the problem condition carefully
+ 1
if v<=r:
by the way, if you just print the value of v your code will work fine.
No need to declare r.
+ 1
You need to print only 0.01 * (2 ** 30)
+ 1
Sebastián ok I understood I was confused because of . I think there should be a comma instead of dot in million. Thanks for telling
+ 1
I'm still a bit confused but I will get there, please tell me if I need to know something.
0
The one between the """" """"
0
Zatch bell but question said print larger amount so why v<= r . if i am missing something please explain
0
Roma Butaku but why the code said you are provided a choice and calculate the results in larger amount
0
What is the meaning of 1.000.000 here
0
As Roma Bataku said, you should read the problem more carefully. It says you must choose $ 1million or $ 0.01 that doubles each day by 30 days. No need to calculate 1*(2**30).
0
v = 0.01 *(2**30)
r = 1*(2**30)
if v <= r:
print(v)
else:
print(r)