This function takes two numbers as parameters, the first number being the coefficient, and the second number being the exponent.
Your function should multiply the two numbers, and then subtract 1 from the exponent. Then, it has to print out an expression (like 28x^7). "^1" should not be truncated when exponent = 2.
For example:
derive(7, 8)
In this case, the function should multiply 7 and 8, and then subtract 1 from 8. It should output "56x^7", the first number 56 being the product of the two numbers, and the second number being the exponent minus 1.
derive(7, 8) --> this should output "56x^7"
derive(5, 9) --> this should output "45x^8"
Notes:
- The output of this function should be a string
- The exponent will never be 1, and neither number will ever be 0
Solution:
def derive(coefficient, exponent):
return f'{coefficient * exponent}x^{exponent - 1}'
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0915. Beginner - Reduce but Grow (0) | 2022.09.15 |
---|---|
0914. Rock Paper Scissors! (0) | 2022.09.14 |
알고리즘 포스팅 관련 공지 (0) | 2022.09.13 |
0912. Fake Binary (0) | 2022.09.13 |
0911. Add Length (0) | 2022.09.11 |