0

Can you use eval as a calculator in python?

I know that eval covers all the basic operations, my only problem is that users may not know how to use it, resulting in many syntax errors. Also, you can input really any python function into eval(), so what I’m wondering is, is eval() a viable solution for calculator programs?

15th Jun 2023, 12:54 PM
Jin
Jin - avatar
2 Antworten
+ 5
No, using eval() for a calculator isn't a good idea. Take a look at the program which uses eval() to perform a task of a calculator. Look for a comment from Mirielle https://code.sololearn.com/clGB3RIP20to/?ref=app Calculator programs: https://code.sololearn.com/c1xFnov4LlEP/?ref=app https://code.sololearn.com/chZ1vV0x3V0G/?ref=app
15th Jun 2023, 1:10 PM
Lamron
Lamron - avatar
+ 2
Thx lamron!
15th Jun 2023, 1:33 PM
Jin
Jin - avatar