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! 😊 



Python Beginner: For Loop

 Hello, Developer!

Today, we will learn "For Loop". "For loop" repeats indented codes until ending of "In" condition and setting up some value range by "Range"command in "In" condition. You can use Strings, Lists, variables, numbers at "In" condition with "Range" command.

"For Loop" declaration and examples

for Variable in "Strings": # Example: for intro in "Welcome to the Python coding world!":

for Variable in List: # Example: for name in list_friends:

for Variable in range(value): # Example: for index in range(10):

for Variable in range(value_1, value_2) # Example: for index in range(5, 10): 

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

for letter in "Dinosaur":

friends = ["Jim", "Karen", "Kevin"]
for name in friends:

for index in range(10):

for index in range(5, 10):

friends = ["Jim", "Karen", "Kevin"]
for index in range(len(friends)):

for index in range(5):
if index == 0:
print("The first Interaction!")
print("Not first interaction.")

Can you see the same result? Congratulations! Now you can use "For Loop" feature in Python programming. Hope you modify these codes for test and have good understanding of "For Loop" feature. This loop feature is frequently used in usual programming.

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

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...