MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / convert_currency

Function convert_currency

web_programming/currency_converter.py:178–187  ·  view source on GitHub ↗

https://www.amdoren.com/currency-api/

(
    from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = ""
)

Source from the content-addressed store, hash-verified

176
177
178def convert_currency(
179 from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = ""
180) -> str:
181 """https://www.amdoren.com/currency-api/"""
182 # Instead of manually generating parameters
183 params = locals()
184 # from is a reserved keyword
185 params["from"] = params.pop("from_")
186 res = httpx.get(URL_BASE, params=params, timeout=10).json()
187 return str(res["amount"]) if res["error"] == 0 else res["error_message"]
188
189
190if __name__ == "__main__":

Callers 1

Calls 3

jsonMethod · 0.80
popMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected