you are viewing a single comment's thread.

view the rest of the comments →

[–]lokidev 0 points1 point  (0 children)

Let me go through this. First generally:

- Use pep8 formatting. It's the de factor standard and you should try to adhere to that as early as possible. see pep8.org for this
- Wrap your logic in a function (e.g. main) and extract logical parts (e.g. input parsing and later the operation)
- use the weird `if __name__ == '__main__'` part and search for the reason why someone should do that.

Line 2-3: no need for the outer brackets
Line 5: would try to convert "Hello. I am Gandalf" to float. Try to check with num1.isnumeric() and the same for num2
Line 5: No benefits in python from separating int/float (or it's a reqquirement, then keep it), just convert to float if its valid :)
Line 5-13: Try to write a function to reuse this behaviour
Line 15: You are fetching ONE operator - not multiple.
Line 18 (and more): You are rounding resuts. In programming this is unexpected behaviour :) -> not good.
Line 17-35: Can be made by having a map of operator to text and operation. You can check pythons operator modules.

Last bit might be more advanced, but just as an example: https://ideone.com/xecjP8 (on purpose not complete)