I’ve been struggling with the Python Code Challenge: Functions exercise.
Finally, broke some ground today.
- Write a function named tenth_power( ) that has one parameter named num.
The function should return num raised to the 10th power.
def tenth_power(num):
(two spaces indentation) return num ** 10
print(tenth_power(1))
print(tenth_power(0))
print(tenth_power(2))
Output:
1
0
1024
- Write a function named square_root( ) that has one parameter named num.
Use exponents (**) to return the square root of num.
def square_root(num):
(two spaces inedentation) return num ** (1/2)
print(square_root(16))
print(square_root(100))
Output:
4.0
10.0