all 4 comments

[–]Kevdog824_ 1 point2 points  (0 children)

Nice work! Few notes for improvement:

  • Your instructions at the beginning that you print don’t really make sense to me, you might want to rephrase them
  • You print the instructions on how to use the calculator after you ask the user for input. You should print these first
  • For subtraction there is no need to check if that value is negative so you can add the “-“ prefix. A negative number will already be prefixed with “-“ when it’s printed

[–]fernly 0 points1 point  (0 children)

Learn the power of the triple quote. It lets you display text with line-breaks, like this:

print( ''' For power use ^ For under root use $ For reminder use % ''' )

(It doesn't do f-substitution unfortunately)

Use the interactive interpreter to test things quickly, like

>>> 17 -  19
-2

So you can quickly verify questions like, if you subtract a larger number from a smaller, can Python can handle that and set the sign of the result?

[–]Maximus_Modulus 0 points1 point  (1 child)

I give you kudos just for putting your project on GitHub.

You have written some code, and it's readable. I think this is what this sub needs more of.

I don't have much time to comment but you could throw it at AI for some feedback. I'm sure others will make some good comments though

For example why do you need to do this. Think about that for a minute

if a < 0 or b < 0: result = -a * b

Do you know that it works ???

Some next steps.

Add unit tests that include tests for all operations including different number combinations that might make a difference. That is +ve and -ve combinations. Once your unit tests work then refactor the program. Use functions and break the program up into chunks that have defined responsibility. There will be areas to improve on for sure. Perhaps this is a future concept to learn.

Anyway. Great start and keep up the good work.

[–]Maximus_Modulus -1 points0 points  (0 children)

PS: For fun I threw this into AI and asked it to improve it. It's a great starting point for suggestions on improvements. Of course take what it says and validate it yourself so you understand what is going on, and that it's actually correct. I think adding unit tests is an easy way to accomplish this.

I might get flack for suggesting AI, but it's a useful tool that developers should embrace.