Share your repls and programming experiences

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

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.)

Voters
LeoRomano14
ANDREWVOSS
Comments
hotnewtop
ApoorvAgrawal

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

ANDREWVOSS

@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

@ANDREWVOSS
how doesn't it work, it works for me

ANDREWVOSS

@ApoorvAgrawal The divide function multiplies instead

ANDREWVOSS

@ApoorvAgrawal like this

CodingCactus

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

ANDREWVOSS

@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.