python Is there any way to format formulas for input
def demo(n): a = '32{}'.format(n) print(32%3) print(a)if __name__ == '__main__': demo("%3") # Expect to return to 2 demo("//3") # Expect to return to 10""">> 32%3 The expected output is 32%3 == 2>> 32//3 The expected output is 32//3 == 10"""
You can use eval Function evaluates the value of an expression .
def demo(ex): return(eval(ex))print(demo('32%3'))print(demo('32//3'))