r/learnpython • • 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!

https://github.com/PASACore/Calculator_CMD_

0 Upvotes

10 comments sorted by

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.

3

u/Valuable_Corner4797 1d ago

This idea had never occurred to me; I will adjust the code based on what you’ve suggested.

1

u/TheRNGuy 1d ago

You need UI and use OOP, events instead of while loop.

1

u/CptBadAss2016 1d ago

Look into the "shunting yard algorithm"

-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