0
exec/eval difference
whats the difference between exec an eval in Python
2 Answers
+ 7
The eval function evaluates a Python expression, which yields a value, which is then returned by the function.
The exec function takes any Python code and executes it. It doesn't return a value.
+ 2
correct me if i am wrong
eval function takes a string as parameter which contains mathematical operations.
example -
mathEq = " 5+6*3+8/2"
print (eval(mathEq))
and on other side exec function can have python keywords in its parameter string