# John B. Schneider # CptS 111 # 1/24/2012 # HW 3b # A program to evaluate an arithmetic expression for a given value. def main(): print( """Enter an arithmetic expression in terms of the variable x. In addition to x, your expression may contain numeric constants and parentheses. The expression can use the following operators: +, - <=> addition, subtraction /, * <=> float division, multiplication // <=> integer division % <=> modulo (remainder) ** <=> exponentiation """) exp_str = input("Enter expression: ") x = eval(input("Enter numeric value for x: ")) print() print("f(x) =", exp_str) print("f(", x, ") = ", eval(exp_str), sep="") main()