반응형
Create a function that converts US dollars (USD) to Chinese Yuan (CNY) . The input is the amount of USD as an integer, and the output should be a string that states the amount of Yuan followed by 'Chinese Yuan'
Examples (Input -> Output)
15 -> '101.25 Chinese Yuan'
465 -> '3138.75 Chinese Yuan'
The conversion rate you should use is 6.75 CNY for every 1 USD. All numbers should be represented as a string with 2 decimal places. (e.g. "21.00" NOT "21.0" or "21")
Solution:
def usdcny(usd: int, exc: int = 6.75):
return f"{usd*exc:.2f} Chinese Yuan"
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1023. No Loops 2 - You only need one (0) | 2022.10.23 |
---|---|
1022. Area of a Square (0) | 2022.10.22 |
1020. Convert a string to an array (0) | 2022.10.20 |
1019. Is it a palindrome? (0) | 2022.10.19 |
1018. Find the smallest integer in the array (0) | 2022.10.18 |