+ 1
Python, calculator and code optimization
I have coded a first (and very nooby) version of a calculator by modifying the one in the Python course. I have added a little bit of text formatting. What can I improve? What can i cut/change in order to have a more optimized code? Also, how can i keep adding/subtracting... more numbers without adding more elif and num3/num4... lines? Is there a way to do so? Thank you in advance! https://code.sololearn.com/c8EXhv3IYeHI/#py
5 ответов
+ 6
First idea:
Dont repeat Input() in each case.
same for ....do you want to add...
+ 5
less is more
https://code.sololearn.com/ck9rtCKNCAdK/?ref=app
+ 3
I mdan if user doesn't enter quit, then get the two numbers no matter which operator. U don't need more than two times input() in your prog.
+ 1
Thank you @Oma Falk, i have added the link, can you see it now?
0
Do you mean assigning variables to the input strings so I don't have to repeat the input() for each operation?
The same goes for ".. add another number" and "..result is:" right?