Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Calculator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ def exponent(ne1, ne2):
"""This function will return the power of two numbers"""
return ne1**ne2


def nth_root(nr1, n):
"""Getting the nth root of nr1"""
return nr1**(1/n)


def subtract(ns1, ns2):
""" This function will return the difference of two numbers """
return ns1 - ns2
Expand All @@ -26,20 +28,27 @@ def divide(nd1, nd2):
return nd1 / nd2


def modulo(nmo1, nmo2):
""" This function will return the remainder of the division of two numbers"""
return nmo1 % nmo2


operations = {
"+": add,
"-": subtract,
"*": multiply,
"/": divide,
"^": exponent,
"√": nth_root
"√": nth_root,
"%": modulo
}


def calculator():
""" This function contains the code that will work as you wish to proceed \
an operation """
num1 = float(input("What's the first number?(to pick √, hold alt + 251 (on numpad)): "))
num1 = float(
input("What's the first number?(to pick √, hold alt + 251 (on numpad)): "))
for symbol in operations:
print(symbol)
should_continue = True
Expand Down