Advertisement
SimeonTs

SUPyF Functions - 06. Math Power

Jun 15th, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. """
  2. Functions and Debugging
  3. Проверка: https://judge.softuni.bg/Contests/Compete/Index/922#5
  4.  
  5. 06. Math Power
  6.  
  7. Условие:
  8. Create a function that calculates and returns the value of a number raised to a given power:
  9.  
  10. Examples
  11. Input:
  12. 2
  13. 8
  14. Output:
  15. 256.0
  16. Input:
  17. 1.5
  18. 3
  19. Output:
  20. 3.375
  21.  
  22. Hints
  23. 1.  As usual, read the input
  24. 2.  Create a function which will have two parameters - the number and the power, and will return a result
  25. 3.  Print the result with no specific formatting.
  26. """
  27.  
  28. # Това е по - чистият вариянт :):
  29. # В тази опция само ако се извика функцията, както по- долу: math_power(). Тогава ще се търси инпут, ще смята и ще
  30. # върне резултата.
  31.  
  32. # def math_power(num=(int(input())), power=int(input())):
  33. #    total = num ** power
  34. #    print(f"{total}")
  35.  
  36.  
  37. # math_power()
  38.  
  39.  
  40. def math_power(num, on_power):
  41.     result = num ** on_power
  42.     return result
  43.  
  44.  
  45. numbers_to_turn = math_power(float(input()), int(input()))
  46.  
  47. print(numbers_to_turn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement