Skip to content

Commit

Permalink
Update doing_math.py
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlikova authored Jan 27, 2021
1 parent 58c5ee0 commit b991eba
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion source/week-1/variables/doing_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
first_num = 6
second_num = 2

# You can peform a variety of math operations on numeric values
# FIRST WAY OF DOING IT
"""# You can perform a variety of math operations on numeric values
print('addition')
print(first_num + second_num)
print('subtraction')
Expand All @@ -14,3 +15,29 @@
print(first_num / second_num)
print ('exponent')
print(first_num ** second_num)
"""

# SECOND WAY OF DOING IT

# importing operator module
import operator

# using add() to add two numbers
print("The addition of numbers is :", end="")
print(operator.add(first_num, second_num))

# using sub() to subtract two numbers
print("The difference of numbers is :", end="")
print(operator.sub(first_num, second_num))

# using mul() to multiply two numbers
print("The multiplication of numbers is :", end="")
print(operator.mul(first_num, second_num))

# using truediv() to divide two numbers
print("The division of numbers is :", end="")
print(operator.truediv(first_num, second_num))

# using pow() to find the power of two numbers
print("The power of numbers is :", end="")
print(operator.pow(first_num, second_num))

0 comments on commit b991eba

Please sign in to comment.