Download 1A.py from Madhan-Alagarsamy/Python: direct link, hf CLI and curl.
- Browser
- Download file 462 Bytes
-
https://huggingface.co/datasets/Madhan-Alagarsamy/Python/resolve/main/1A.py
- Command line
-
hf download hf://datasets/Madhan-Alagarsamy/Python/1A.py
-
curl -L -o 1A.py https://huggingface.co/datasets/Madhan-Alagarsamy/Python/resolve/main/1A.py
462 Bytes
| def power(x, n): | |
| if n == 0: | |
| return 1 | |
| else: | |
| return x * power(x, n - 1) | |
| print("\tComputing power function using trivial recursion (x^n)") | |
| print("\t-------------------------------------------------") | |
| print("Input") | |
| print("------") | |
| x = int(input("Enter the base value x: ")) | |
| n = int(input("Enter the exponential value n: ")) | |
| r = power(x, n) | |
| print("Output") | |
| print("-------") | |
| print("The value of", x, "power", n, "=", r) | |