Udemy Python day 21 to 30

I made a calculator program

print(math_func.total_num(5.1, "+", 10.9, "*", 8, "-", 15.4, "/",  5.6))

Main

import math_func
import greet

print(math_func.add(1,3,4,5))

print(math_func.add(1,3,4,5,8,9))

print(math_func.multiply(1,3,4,5,8,9))

# kwargs
params = {"name": "Bob"}
greet.greet(**params)

params = {"name": "Bob", "greeting": "Hi"}
greet.greet(**params)


print(math_func.total_num(5.1, "+", 10.9, "*", 8, "-", 15.4, "/", 5.6))

Greet

def greet(name, greeting="Hello"):
print(f"{greeting}, {name}!")

math_func

import numbers

def add(*arg):
total = 0
for x in arg:
total += x
return(total)

def multiply(*arg):
total = 1
for x in arg:
total *= x
return(total)


def total_num(*arg):
total = 0
for x in arg:
if total == 0:
if isinstance(x, (int, float)):
total += x
else:
if isinstance(x, (str)):
operator = x

else:
if operator == "+":
total += x
if operator == "*":
total *= x
if operator == "-":
total -= x
if operator == "/":
total /= x

return total

Output

13
30
4320
Hello, Bob!
Hi, Bob!
20.107142857142858