Share your repls and programming experiences

← Back to all posts
henryeth (183)

Finally, this took SO MUCH effort. FINALLY IT WORKS.

I present to the community:
The best calculator I have ever seen on (so the title could potentially have been clickbait unintentionally, I have not been around for that long...). Following a trio of connected calculators:

This excels them all in all areas. The closest one is Valdez's C++ one but this is far smaller and more efficient, as well as supporting a couple more operators. Do your worst - if you do find a bug, please PLEASE let me know in the comments, I really want this flawless. It will be harder to abuse than Valdez's (I saw what you community did to that comment section) because it will should ignore any invalid characters or valid characters in invalid positions. However, obviously, integer limit is still a problem :braces himself for upcoming abuse of calculator:. Any questions or suggestions (preferably questions) please write them in the comments.

P.S: Please work calculator PLEASE.

Thank you all so much this is by far the most cycles I have ever had!

KnightsOfAzgard (16)

Overall nice calculator.
However, I have found an error in your calculator @henryeth - it cannot handle imaginary numbers (3 + 2i^2 etc.). However, imaginary numbers are a key area in algebra, so this can be called a major error.

Another graphical problem (an extra dot in the end):

It can also be improved by adding equation solvers with variables, like the online calculator of wolfram alpha.

henryeth (183)

@KnightsOfAzgard This calculator isn't meant to do algebra at all. The second dot is a period but yes it can be confusing I will remove it.

KnightsOfAzgard (16)

@henryeth Well, it wouldn't exactly be the best calculator on then... no offense...

henryeth (183)

@KnightsOfAzgard I said it was the best calculator on that I have seen. First, notice the lack of the word "algebra"

print("calculator" == "algebra calculator")
>>> False

and second, note the "that I have seen". Even excluding the second point as it is kind of cheaty, try and find me a better calculator that matches the first point on, or, even better, make one yourself. I would be quite happy to be educated on the matter...

KnightsOfAzgard (16)

@henryeth 'Calculator' may not equal 'Algebra Calculator', but 'Algebra calculator' is a 'calculator' so I suggest you make that clear.

As for finding a better calculator, I take you up on that challenge. emilian1000000's calculator ( can be seen as better because of the average command as well as calculations on '<' and '>'.

henryeth (183)

@KnightsOfAzgard yes and that one is error-proof, ignores invalid characters and handles calculations that are more than "[number][operator][number]"! Oh hang on... it does none of those things

Baconman321 (1096)

@KnightsOfAzgard If algebra is so important, why don't you go make it yourself?

It's going to be really hard, as you will have to parse the variables as well as other concepts in algebra.

Expect no less than 500 lines of code for something as complicated than that...

Coder100 (18057)

is it really a good calculator without making a programming language? @KnightsOfAzgard

Coder100 (18057)

hm that one isn't working very well at all


henryeth (183)

@Coder100 That one is terrible and only works for 2 numbers and one operation.

henryeth (183)

@KnightsOfAzgard @WILLIAMBAEW @Baconman321 @Coder100 new version out now! Do more testing :mechanical laugh:

henryeth (183)

@Baconman321 A few new operators atm (will be more), smaller and more efficient system, handling for multi-character unary operators coming soon.

Baconman321 (1096)

@henryeth Don't forget scientific notation!

1e+10 is the same as 10000000000.

henryeth (183)

@Baconman321 Python has that integrated already i don't need to do it.

henryeth (183)

@Baconman321 idk how python actually use it tbh but it should pop it in for big and small numbers I think

Baconman321 (1096)

@henryeth no I mean add support for parsing scientific exponents.

henryeth (183)

@Baconman321 Actually on second thoughts, I think I may

GrantDeibler (2)

@Baconman321 representing variables in variables is hard.

applicationUFO (5)

Not Clickbait

Totally clickbait
FlaminHotValdez (683)

I saw what you community did to that comment section

I love this community so much.

ShadowHoonter (69)

It also doesn't seem to run negative numbers.

ShadowHoonter (69)

It seems that parentheses don't work.

tarboldz (0)

@ShadowHoonter Well you can write:

The answer is 108.0

It works for me.

Kudos (138)

Nice calculator. If I was doing this I would just eval() it 😁

henryeth (183)

@Kudos :D I agree:

try: print(f"\nThe answer is {eval(input("Enter an expression:\n"))}.)
except NameError: print("Ntr a reel xpresun u ideot.")

best calculator ever.

FlaminHotValdez (683)

@Kudos ...The whole point of this is to make a calculator that doesn't do eval and isn't "Input the operator" "Input one number" "Input another number"

also to beat mine. yes I'm salty
henryeth (183)

@FlaminHotValdez there is some element of truth in that last bit... alas I admit it

randomguy222 (285)

@henryeth welp, looks like you fixed the order of operators

good job!

FlaminHotValdez (683)


You: "If I was doing this I would just eval() it
Also you: makes a legitimate calculator without using eval()

Kudos (138)

🤣 Well I didn't want to be an @AJK4 because it would bring no value to the community.


finally, you got a ton of cycles @henryeth! And the code is sooooooooo complicated that....(what is the append thing over there? what are - char, and other crazy stuff?)

Whippingdot (652)

The code is sooooo simple(not to be mean) @CaptinNeo

henryeth (183)

@Whippingdot agreed. Simple but effective

X24 (30)

@CaptinNeo Append just adds something to the end of a list

FlaminHotValdez (683)

@henryeth damn I'm salty it's so much easier to do in python because of the lambdas. I challenge you to make a version of this without lambdas!

henryeth (183)

@FlaminHotValdez It would be exactly the same - just bigger. It would just be replaced by a bunch if statements in the place where it calls the lambdas. I won't because it is pointless and, as you say, you are being salty :D.

FlaminHotValdez (683)

@henryeth lol yeah at least I admit it though xD. Truth be told though I probably wouldn't be able to do it in Python at all because I'm bad at it because I couldn't find a method to do it w/o stacks.

henryeth (183)

@FlaminHotValdez Just study the code you'll figure it out. I am (spoiler alert) working on a second version with a different, simpler, method.

FlaminHotValdez (683)

@henryeth what the beep how is it possible to be simpler

henryeth (183)

@FlaminHotValdez probs not really "simpler" but more "slightly longer yet more readable and using more straightforward concepts".

henryeth (183)

@FlaminHotValdez Out now - turns out it is simpler as well as the last things I listed.

henryeth (183)

@CaptinNeo @Whippingdot @X24 new version now out feel free to comment on this one too...

X24 (30)

@henryeth I didn't critique anything, just told the guy what append means...

This is injustice!!!

SilvermoonCat (436)

@henryeth nice I suggest making a while loop though so that I can keep using without having to rerun, everything else looks good :D

henryeth (183)

@SilvermoonCat that is done now in the new version (check it out still on this post)



TomMalone (1)

SIR 66X0 IS NOT 660

Smart0ne (743)

I typed in 2+2/2x2 and it said the answer is 2.090909090909091.

BD103 (139)

On Valdez's Calculator:

On your calculator:

Quoting Coder100, "ah yes, math".

(No hate, ngl. I could never do this without eval()!)

FlaminHotValdez (683)

@BD103 then you are bad. Use exec()

ShadowHoonter (69)

I don't know why, but % don't work, it doesn't say invalid input, it will break.

henryeth (183)

@ShadowHoonter it did that with all operations if you had operation followed by nothing at the end - fixed now.



Nice Calculator 😎
But...there is a bug.

henryeth (183)

@XThacker FINALLY fixed that took too long... like almost an hour probs...

BobTheTomatoPie (3360)

now this is impressive python coding

henryeth (183)

@BobTheTomatoPie wooooow big names are coming tysm

BobTheTomatoPie (3360)

np you deserve it! I would not be able to do this in python even back when I used to use it, I was worried to click on this cause i thought it would be another eval statement, but I was very wrong, this is just awesome @henryeth

henryeth (183)

@BobTheTomatoPie LoL I can imagine that, someone making a post with this title and the start of this description, and upvoting it with 25 bots. And the code is just:

print(eval(input("Nter th xpreson")))
BobTheTomatoPie (3360)

yea lol, even CC did that once @henryeth

FlaminHotValdez (683)

@BobTheTomatoPie Which CC? CyanCoding or CodingCactus?

henryeth (183)

@BobTheTomatoPie I finished the second version and it is now on this post.

ColePete (30)

really good, minor suggestion, make it a loop to keep going like my calculator.

henryeth (183)

@ColePete have done, and that feature is still in the second version that is now out.

TravisRaney (11)

@ColePete just making my movie story season 1 and needing help though, I got it in my team

XanthusPettitt (10)

hi, im currently making a calculator that does, well everything and I could use some more help

BenCavanaugh (20)

this should equal 1 or 16???


You can't use variables :trololololo:

henryeth (183)

@BenCavanaugh Think about it, did you genuinely expect that to work?

Kudos (138)

Does this using the shunting-yard algorithm? It certainly looks so.

Soccer135246 (7)


tarboldz (0)

Put -69*69/420
The answer should be negative, returns POSITIVE

Put 4^-0.5
The nnswer should be 0.5. Instead returns the number if the exponent were POSITIVE (this is, 0.5), returning TWO.

You shouldn´t be SO POSITIVE with your calculator, SIR HENRY.

InvisibleOne (2931)

Or, you could just like do this: print(eval(input("Enter you expression: "))) since python can do math

RhinoRunner (866)

@InvisibleOne True, but statements like that can backfire.
Plugging in a user input to eval without making sure it is an equation first can let people read/write/create files, which is very bad.
If you inspect the code here, you can see how it won't run the eval if it's not an equation.

zplusfour (914)

i tried to do quik mafs

ComicBro (0)

You should make a ans option, so you can use your past answer as a number

RishabTirupath1 (0)

One thing that could be improved on is floating-point math. It is hard for base-2 computers to do simple things like add 0.1 and 0.2, but you could try a workaround, like multiplying the float until it is an int.

jagnar (4)

when you are using this (For example it says 5 plus 5 = 55) Could you please fix this.

dogsledding (0)

@jagnar use the actual symbols for the equation (+,/,*,^, etc)