#Python exchangeable_value
33 messages · Page 1 of 1 (latest)
hello no sorry I didn't use the (denomination) argument because I don't know where to put it in the formula @quartz summit
You need to compute the amount of money you can get back, assuming you can only get money in a single denomination
hi I'm trying to include the denomination but I'm doing it wrong it looks like here's my code: ``` def exchangeable_value(budget, exchange_rate, spread, denomination):
exchange_non_decimal = exchange_rate * 10
exchange_decimal = exchange_non_decimal/100
exchange = spread + exchange_decimal
exchangealble_rate = int(budget/exchange)
test = exchangealble_rate / denomination
return int(test * denomination)```
What effect does the first two lines of the function have?
What effect do the last two lines have?
b = a * 10
c = b/100
...
y = x / denomination
return int(y * denomination)
What effect does the first two lines of the function have? it is these lines which create the number to add it to the spread, it is he which transforms a 1.20 into 0.12
What effect do the last two lines have?
it divides the exchange rate obtained to prepare it for the next formula which is to multiply it by the denomination
a / x * x doesn't do very much. It returns the original value.
It's helpful to know what you're trying to do. Dividing just to have a division operator isn't very useful.
a * 10 / 100 is the same as a / 10. That's not correct either.
>>> exchangeable_value(127.25, 1.20, 10, 20)
80
Do you understand how to go from those inputs to that output?
Hi sorry for the late response for the input/output I tried to do the formula on my side using the calculator on my laptop I always had a difference in the result but with this formula a / x * x I obtained the 1.32
that I added to the spread to be frank I don't know what mathematical formula I should apply @quartz summit
Maybe it can help if you try to explain your approach to me.
Treat me as your Rubber Duck and explain what you're doing and why you are doing it, step by step.
ok I have four variables budget, exchange_rate, spread, denomination my goal is to transform the budget to the exchange rate of the country where we want to change the currency I know that with the spread transform into decimal and add to exchange_rate, I can divide by the budget and get closer to the result of the answer but the denomination I don't know what to do with it in the formula other than divide it by the exchange rate modify and subtract it from the budget with which I have already done the calculation with the spread modify and I believe that it is from there that I go into the unknown
whoa! please slow down.
my goal is to transform the budget to the exchange rate of the country where we want to change the currency
ok.
I know that with the spread transform into decimal and add to exchange_rate, I can divide by the budget and get closer to the result of the answer
"closer" won't do, you need "correct".
Let's focus on the first part of the function:
exchange_non_decimal = exchange_rate * 10
exchange_decimal = exchange_non_decimal/100
exchange = spread + exchange_decimal
What is that supposed to do?
Ok sorry please excuse me for the typo well for this code it is supposed to transform my spread into decimal, wait ok I see there is an error it is my spread which must be decimal not my exchange_rate ```
spread_decimal = spread/100
exchange_rate_spread_decimal = exchange_rate + spread_decimal
divided_budget = int(budget/exchange_rate_spread_decimal)
denomination_divided = int(denomination/exchange_rate_spread_decimal)
return divided_budget-denomination_divided
Increase your chance of getting help and look like a pro by sharing codeblocks not images. For example, you can type the following. Note, the ``` must be on their own line.
```
for number in range(10):
total += number;
```
Discord will render that as so:
for number in range(10):
total += number;
Click here to learn more about codeblocks: https://exercism.org/docs/community/being-a-good-community-member/writing-support-requests
Please explain this line:
exchange_rate_spread_decimal = exchange_rate + spread_decimal
Does it match the explanation in task #6:
"If 1.00 EUR == 1.20 USD and the spread is 10, the actual exchange rate will be: 1.00 EUR == 1.32 USD because 10% of 1.20 is 0.12, and this additional fee is added to the exchange."
that's it
then I divide it by the budget and also for the denomination from which I will subtract the results
Sorry, I don't understand. Does that line match the explanation?
When you calculate the exchange_rate_spread_decimal for the exchange_rate == 1.20 and the spread == 10, what do you get?
Sorry, I don't understand. Does that line match the explanation? for this question yes the line corresponds to the explanation of the exercise for addition
please calculate that once more for me
When you calculate the exchange_rate_spread_decimal for the exchange_rate == 1.20 and the spread == 10, what do you get? I get this for example 10.709999999999999
that's far off from the correct value 1.32 that is explained in the instructions.
yes not false can be reduced to two digits after the decimal point
there might be some language-barrier issues going on here (I'm not a native English speaker), so I'll try to summarize and rephrase it:
Your first task (as explained in the instructions) is to calculate the "actual exchange rate".
The instruction give an example where the exchange_rate is 1.20 and the spread is 10.
They show the calculation that gives the actual exchange rate 1.32.
Do you understand the calculation in the example?
Do you understand what your implementation does differently?
Yes sorry I made a mistake it's the wrong number the result it gives is 1.3 and what language do you normally speak because I'm French
Hello neighbor, I'm from Germany.
Great, you found an issue. That's the first step. Now you have to correct the calculation.
Cool long live Germany yes I found the first step more than correcting the calculation I will leave you and wish you good evening