What is the problem in the code | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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.

28th Dec 2020, 1:05 PM
Charchit Dahiya
Charchit Dahiya - avatar
12 ответов
+ 2
where's your code tho? we don't see what you're thinking inside the brain.
28th Dec 2020, 1:08 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
+ 2
You need calculate only 1 cent doubled every day during the 30 days and print result, read the problem condition carefully
28th Dec 2020, 1:24 PM
Roma Butaku
Roma Butaku - avatar
+ 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.
28th Dec 2020, 1:12 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
You need to print only 0.01 * (2 ** 30)
28th Dec 2020, 1:20 PM
Roma Butaku
Roma Butaku - avatar
+ 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
29th Dec 2020, 9:02 AM
Charchit Dahiya
Charchit Dahiya - avatar
+ 1
I'm still a bit confused but I will get there, please tell me if I need to know something.
4th Jun 2021, 3:13 PM
Katana Gamez
Katana Gamez - avatar
0
The one between the """" """"
28th Dec 2020, 1:09 PM
Charchit Dahiya
Charchit Dahiya - avatar
0
Zatch bell but question said print larger amount so why v<= r . if i am missing something please explain
28th Dec 2020, 1:16 PM
Charchit Dahiya
Charchit Dahiya - avatar
0
Roma Butaku but why the code said you are provided a choice and calculate the results in larger amount
28th Dec 2020, 1:22 PM
Charchit Dahiya
Charchit Dahiya - avatar
0
What is the meaning of 1.000.000 here
28th Dec 2020, 3:33 PM
Charchit Dahiya
Charchit Dahiya - avatar
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).
29th Dec 2020, 7:34 AM
Sebastián Rivera
0
v = 0.01 *(2**30) r = 1*(2**30) if v <= r: print(v) else: print(r)
20th Apr 2021, 9:26 AM
James Kenneth Almerol
James Kenneth Almerol - avatar