← Back to challenges

Key - Mouse (Logic)

PythonHardlogicmathlanguage_fundamentals

Instructions

A keyboard and a mouse cost in total x, knowing that the keyboard costs y more than the mouse, calculate the price of the mouse. Round the price of the mouse.

Examples

KM({"Total": "10.00$", "Difference": "0.40$", "Mouse": "?"})
➞ {"Total": "10.00$", "Difference":"0.40$", "Mouse": "4.8$"}

KM({"Total": "90.00$", "Difference": "5.40$", "Mouse": "?"})
➞ {"Total": "90.00$", "Difference": "5.40$", "Mouse": "42.3$"}

KM({"Total": "1.30$", "Difference": "0.80$", "Mouse": "?"})
➞ {"Total": "1.30$", "Difference": "0.80$", "Mouse": "0.25$"}

Notes

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.