Algorithms and Data Structures with PythonChapter 55

5. Adding Advanced Arithmetic Functions

Section 5 of 8-~ 12 min read-Synced from Cuantum content

While our calculator already handles basic arithmetic, let's add a few more advanced operations such as power, square root, and factorial.

import math def power(x, y):    return x ** y def square_root(x):    return math.sqrt(x) def factorial(x):    if x == 0:        return 1    return math.factorial(x)