One Line Calculator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

One Line Calculator

print(eval(input("Enter math expression to evaluate.\n"))) https://code.sololearn.com/cx1TgWN410RL

16th Jul 2017, 5:44 AM
David Ashton
David Ashton - avatar
3 Answers
+ 1
Here a safe version (David your version has the same security problem) https://code.sololearn.com/c0zzPGplv8Yy/?ref=app
16th Aug 2017, 9:53 PM
VcC
VcC - avatar
+ 4
VcC That is clever! Pretty much impossible to create malicious code out of the permitted input.
17th Aug 2017, 12:35 AM
David Ashton
David Ashton - avatar
- 1
Nice !!! In 4 lines another one with trigonometry , deep learning or any existing python package. Plus some serious security holes ! https://code.sololearn.com/cXmeQ5FUwpsQ/?ref=app
16th Aug 2017, 5:10 PM
VcC
VcC - avatar