r/learnpython • u/Valuable_Corner4797 • 1d ago
Easy Calculator (Python) :)
I didn't like the Windows Calculator, so I decided to develop my own CMD-based calculator. It's open-source, so anyone is welcome to use it!
1
1
-1
u/Educational_Virus672 1d ago
its nice seeing someone try something like this but im gonna be honest your better off using eval, i see your your problem solving potential but in programming some thigns like this is almost always exist and a programmer should learn to research and adapt keep up the work!
ask = input(">")
try :
print(eval(ask))
except SyntaxError :
print("invalid")5
u/mandradon 1d ago
This is terrible advice. eval should almost never be used due to the ability for command injection into programs.
1
u/SpiderJerusalem42 1d ago
I think for toys you play with on your own computer it's fine, but I wouldn't put it in a GitHub repo.
-2
u/No-Formal7513 1d ago
good job, I saw the source code, and well....I am a Java guy, so sorry for that, I couldn't break down your source code to understand
But hey, It also have a good presentation, here is my Github:
https://github.com/Aditya120910
can visit it, if you like to
1
u/Educational-Paper-75 1d ago
Why not ask for the control words when you ask for the first float a. Saves the user having to enter a float he has no intention of using. You may also be able to refactor the main while loop getting rid of yeni and some of the continue or break statements. And use elif when appropriate.