+ 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

27th Mar 2020, 2:45 PM
Flavio
5 odpowiedzi
+ 6
First idea: Dont repeat Input() in each case. same for ....do you want to add...
27th Mar 2020, 2:51 PM
Oma Falk
Oma Falk - avatar
27th Mar 2020, 8:55 PM
Louis
Louis - avatar
+ 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.
27th Mar 2020, 6:16 PM
Oma Falk
Oma Falk - avatar
+ 1
Thank you @Oma Falk, i have added the link, can you see it now?
27th Mar 2020, 2:50 PM
Flavio
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?
27th Mar 2020, 3:08 PM
Flavio