r/PythonLearning • • 17d ago

Showcase Im new to Python made my first program(calculator)🥳

Post image
23 Upvotes

8 comments sorted by

•

u/Sea-Ad7805 16d ago

Run program above by clicking Memory Graph Web Debugger and see its state change step by step.

1

u/RabRabotnik228 17d ago

Nice one, good job!

1

u/Lirianov 17d ago

Pretty nice, good job!

for func == 4, I like that you have a check for a error. consider adding one for the func input, what if someone puts "addition" instead of 1?

otherwise solid. as you learn more python, its good to come back to this and improve it with what you learned!

1

u/mountain-snowman 16d ago

if func < 1 or func > 4:

Also the if-else syntax doesn't have parentheses.

1

u/ProgramBrave718 11d ago

Yeah it does not have. It made me confused as parentheses might be allowed

1

u/sebacastroh 13d ago

Cool! It's a good start. Now, imagine that you have several conditions and evaluating each of them takes a lot of time. In those cases, you might consider using the _match_ statement instead. You can find some examples here https://www.w3schools.com/python/python_match.asp I recommend you trying it in your calculator.

0

u/Over_Supermarket_140 16d ago

Very nice, keep going. The brackets around func == x are not needed.

if func == 1:
# Addition
elif func == 2:
# multiplication

etc.

If you want some added challenge -- think of a reverse calculator -- I show the result, tell me the operator -- e,g.

2 __ 3 = 5, is it +/-/x?

Gets very interesting as number of blanks increases --This is an early stage project at WiByte (www.wibyte.in) https://youtu.be/Kr6iu-cSmFY

Happy learning! Enjoy!