I am just starting out with python3, and I'm trying to write a simple exponential function. Now, what I've written below does work, however, I want to change the code in such a way, that it would allow for user input and then give out the answer based on that input.
def raise_to_power(base_num, pow_num):
result = 1
for index in range(pow_num):
result = result*base_num
return result print(raise_to_power(2, 3))
print(raise_to_power(2, 3))
This is what my attempt at getting the new code to work looks like.
base_num = float(input("Enter base number: "))
pow_num = float(input("Enter power number"))
def raise_to_power(base_num, pow_num):
result = 1
for index in range(pow_num):
result = result*base_num
return result
print(raise_to_power)
However, I consistently get the following message as a result instead of an answer
<function raise_to_power at 0x7f8fe15baf70>
What do I do about this?
print(raise_to_power(base_num, pow_num))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.