## This project is a simple math calculator.  You input either first number, operand, second number or first number, operand.  It does basic math: *, /, +, and -.  It does powers, factorials, circumference and area of a circle.

### my_functions.py code

I placed all the arguments that will be called into one file called my_functions.py.  I will be calling them into the other programs I am running.

get_truth() uses relative operators so that you can use either words or symbols for the math functions. it lists each keyword and value
math_func() uses if – elif statements. I also use
{:.xf}”.format(result) to round the numbers where x is the precision
get_truthWQ() allows the operations in words without quotes.  It is 2 lines.

It also uses Fraction to display the number as a fraction instead of a decimal.

`#!/usr/bin/python3import mathimport operatordef get_truth(firstnum, op, secondnum):    rel_ops = {        '+': operator.add,        '-': operator.sub,        '*': operator.mul,        '/': operator.truediv,        '//': operator.floordiv,        'operator.add': operator.add,        'operator.sub': operator.sub,        'operator.mul': operator.mul,        'operator.truediv': operator.truediv,        'operator.floordiv': operator.floordiv,        '>': operator.gt,        '<': operator.lt,        '>=': operator.ge,        '<=': operator.le,        '==': operator.eq,        '!=': operator.ne,        'operator.gt': operator.gt,        'operator.lt': operator.lt,        'operator.ge': operator.ge,        'operator.le': operator.le,        'operator.eq': operator.eq,        'operator.ne': operator.ne    }    return rel_ops[op](firstnum, secondnum);def get_truthWQ(firstnumWQ=0, op=0, secondnumWQ=0):    return op(firstnumWQ, secondnumWQ);def math_func(firstnum=0, operand=0, secondnum=0):    if operand == '*':        print(firstnum, '*', secondnum, '=', firstnum * secondnum)        return;    elif operand == '/':        result = firstnum / secondnum        if result - int(result) == 0:            print(firstnum, '/', secondnum, '=', int(result))        else:            print(firstnum, '/', secondnum, '=', "{:.4f}".format(result))        return;    elif operand == '+':        result = firstnum + secondnum        print(firstnum, '+', secondnum, '=', result)        return;    elif operand == '-':        result = firstnum - secondnum        print(firstnum, '-', secondnum, '=', result)        return;    elif operand == 'sqroot':        result = math.sqrt(firstnum)        if result - int(result) == 0:            print('square root of', firstnum, '=', int(result))        else:            print('square root of', firstnum, '=', "{:.4f}".format(result))        return;    elif operand == 'powerof':        from fractions import Fraction        result = math.pow(firstnum, secondnum)        # if the result returns an integer, it will only print the integer, else it will print 2 decimal places        # This also prints the fractional value not the decimal        if result - int(result) == 0:            print(firstnum, 'raised to the power of', Fraction(secondnum).limit_denominator(100), '=', int(result)                  )        else:            print(firstnum, 'raised to the power of', Fraction(secondnum).limit_denominator(100),                  '=', "{:.2f}".format(result))        return;    elif operand == 'fact':        result = math.factorial(firstnum)        print(firstnum, '! is =', result)        return;    elif operand == 'circarea':        result = math.pi * firstnum ** 2        print('area of circle with radius of', firstnum, 'is', "{:.4f}".format(result))        return;    elif operand == 'circcircum':        result = math.pi * 2 + firstnum        print('circumference of circle with radius of', firstnum, 'is', "{:.4f}".format(result))        return;    elif firstnum == operand == secondnum == 0:        print('you forgot the all the inputs')        return;    elif operand == secondnum == 0:        print('you forgot the operand')        return;`

## Arguments.py

You have basic math, sqroot, fact for factorial, powerof, cirarea, circircum for circle area and circumference
`#!/usr/bin/env python3from my_functions import *math_func()math_func(5)math_func(5, '*', 4)math_func(6, '+', 4)math_func(10, '/', 2)math_func(7, '/', 3)math_func(8, '-', 4)math_func(400, 'sqroot')# even adding the secondnum will not break it because it isn't usedmath_func(5, 'sqroot', 1)math_func(200, 'powerof', 2)math_func(200, 'powerof', 3)# raising a number to .5 is same as square rootmath_func(16, 'powerof', 0.5)# cubed root of a numbermath_func(27, 'powerof', (1 / 3))# fourth root of a numbermath_func(81, 'powerof', (1 / 4))math_func(339019928, 'powerof', .05)math_func(10, 'fact')math_func(4, 'circarea')math_func(4, 'circcircum')`

## The output

`you forgot the all the inputsyou forgot the operand5 * 4 = 206 + 4 = 1010 / 2 = 57 / 3 = 2.33338 - 4 = 4square root of 400 = 20square root of 5 = 2.2361200 raised to the power of 2 = 40000200 raised to the power of 3 = 800000016 raised to the power of 1/2 = 427 raised to the power of 1/3 = 381 raised to the power of 1/4 = 3339019928 raised to the power of 1/20 = 2.6710 ! is = 3628800area of circle with radius of 4 is 50.2655circumference of circle with radius of 4 is 10.2832`

Process finished with exit code 0

I am passing the relative operator in quotes with the variable to the operator function.

`import mathimport operatordef get_truth(firstnum, op, secondnum):     rel_ops = {            '+': operator.add,            '-': operator.sub,            '*': operator.mul,            '/': operator.truediv,            '//': operator.floordiv,            'operator.add': operator.add,            'operator.sub': operator.sub,            'operator.mul': operator.mul,            'operator.truediv': operator.truediv,            'operator.floordiv': operator.floordiv,            '>': operator.gt,            '<': operator.lt,            '>=': operator.ge,            '<=': operator.le,            '==': operator.eq,            '!=': operator.ne,            'operator.gt': operator.gt,            'operator.lt': operator.lt,            'operator.ge': operator.ge,            'operator.le': operator.le,            'operator.eq': operator.eq,            'operator.ne': operator.ne     }     return rel_ops[op](firstnum, secondnum);print('Testing MDAS')print('17 + 9 =', get_truth(17, '+', 9))print('17 - 9 =', get_truth(17, '-', 9))print('17 * 9 =', get_truth(17, '*', 9))print('17 / 9 =', get_truth(17, '/', 9))print('17 // 9 =', get_truth(17, '//', 9))print('')print('17 operator.add 9 =', get_truth(17, 'operator.add', 9))print('17 operator.sub 9 =', get_truth(17, 'operator.sub', 9))print('17 operator.mul 9 =', get_truth(17, 'operator.mul', 9))print('17 operator.truediv 9 =', get_truth(17, 'operator.truediv', 9))print('17 operator.floordiv 9 =', get_truth(17, 'operator.floordiv', 9))print('')print('Testing truth or false')print('1.0 > 0.0 is', get_truth(1.0, '>', 0.0))print('1.0 < 0.0 is', get_truth(1.0, '<', 0.0))print('1.0 >= 0.0 is', get_truth(1.0, '>=', 0.0))print('1.0 <= 0.0 is', get_truth(1.0, '<=', 0.0))print('1.0 == 0.0 is',get_truth(1.0, '==', 0.0))print('1.0 != 0.0 is',get_truth(1.0, '!=', 0.0))print('')print('1.0 operator.gt 0.0 is', get_truth(1.0, 'operator.gt', 0.0))print('1.0 operator.lt 0.0 is', get_truth(1.0, 'operator.lt', 0.0))print('1.0 operator.ge 0.0 is', get_truth(1.0, 'operator.ge', 0.0))print('1.0 operator.le 0.0 is', get_truth(1.0, 'operator.le', 0.0))print('1.0 operator.eq 0.0 is', get_truth(1.0, 'operator.eq', 0.0))print('1.0 operator.ne 0.0 is', get_truth(1.0, 'operator.ne', 0.0))print('')print('Operator without quotes around it')def get_truth(inp, op, cut):    return op(inp, cut);print('1.0 operator.gt 0.0 is', get_truth(1.0, operator.gt, 0.0))print('1.0 operator.lt 0.0 is', get_truth(1.0, operator.lt, 0.0))print('1.0 operator.ge 0.0 is', get_truth(1.0, operator.ge, 0.0))print('1.0 operator.le 0.0 is', get_truth(1.0, operator.le, 0.0))print('1.0 operator.eq 0.0 is', get_truth(1.0, operator.eq, 0.0))print('1.0 operator.ne 0.0 is', get_truth(1.0, operator.ne, 0.0))`

## The output

`Testing MDAS17 + 9 = 2617 - 9 = 817 * 9 = 15317 / 9 = 1.888888888888888817 // 9 = 117 operator.add 9 = 2617 operator.sub 9 = 817 operator.mul 9 = 15317 operator.truediv 9 = 1.888888888888888817 operator.floordiv 9 = 1Testing truth or false1.0 > 0.0 is True1.0 < 0.0 is False1.0 >= 0.0 is True1.0 <= 0.0 is False1.0 == 0.0 is False1.0 != 0.0 is True1.0 operator.gt 0.0 is True1.0 operator.lt 0.0 is False1.0 operator.ge 0.0 is True1.0 operator.le 0.0 is False1.0 operator.eq 0.0 is False1.0 operator.ne 0.0 is TrueOperator without quotes around it1.0 operator.gt 0.0 is True1.0 operator.lt 0.0 is False1.0 operator.ge 0.0 is True1.0 operator.le 0.0 is False1.0 operator.eq 0.0 is False1.0 operator.ne 0.0 is True`