Popular Posts

Friday, August 28, 2020

Python Beginner: Exponent Function

 Hello, Developer!


Today, we will build an"Exponent Function" as exponent math function using "For Loop" and "Input" feature. You will input base number and power number and "Exponent Function" will calculate result value and print out it.


Here, I show full exercise codes and execution result as following.

base_num = int(input("Please input base number of exponent calculation: "))
pow_num = int(input("Please input power number of exponent calculation: "))

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(base_num, pow_num))

Can you see the same result? Great job! Now you can use "Input", "For Loop" for mathematical calculations.

Hope you modify more this program as you want and verify execution result. Sometimes, you have to fix the errors but through these debugging experience you will be a better developer.

Alright, see you on next post, Python developer! 😊 



 



 


No comments:

Post a Comment

Python - Web crawling exercises

Hello Python developer! How are you? Hope you've been good and had wonderful time with Python. There are 10 Python requests module exerc...