Share your repls and programming experiences

← Back to all posts
I made a calculator in python without importing 'math' or using 'eval'

On the first line, type your first number, on the second line, type your operator, on the third line, type the second number, and on the fourth line, type "=" and press enter.

The syntax should look like this:

The operators are:

"+" for addition

"-" for subtraction

"*" or "x" for multiplication

"/" for division

"^" or "**" for exponents

"//" or "/*" for roots (example: 8 // 3 is the cube root of 8.)

"," for fractions (example: 2 , 3 is the fraction 2/3.)

ApoorvAgrawal (51)

maybe you should make it so that you can have mixed operations and not only 2 numbers and a gui using tkinter.


@ApoorvAgrawal Thanks for the idea. The code for this project is broken and my efforts to fix it are going nowhere, so I might delete this post later on, considering that it links to a repl that doesn't work.

ApoorvAgrawal (51)

how doesn't it work, it works for me


@ApoorvAgrawal The divide function multiplies instead

CodingCactus (4366)

while True: print(eval(input("Enter calculation:\n")))


@CodingCactus Fair enough. That is a lot more simple, but my build supports fractions and custom syntax, so I didn't completely waste my time.