7/6/2023 0 Comments Python console calculatorsquare computes the square root, exponent returns a square where I would expect any exponentiation, get_result gets nothing but prints instead, the module names are confusing. NamingĪ lot of your module and function names are confusing or misleading. In fact, I'd argue a simple project like this would benefit from being in a single source file. If you wanted to change how user inputs are handled (which you should, more on that later), now you have to apply changes all over your code, for something quite basic. For example, get_one_variable() calls get_variable() in another module. In your case, a single feature may get split across multiple functions, possibly across multiple modules. You should aim for each function to fully implement a single feature of your code. While this is generally a good idea, I fail to understand the logic you used here. You divided your code in multiple modules and functions. Return s(variables) / math.sin(variables) Operation.py This module consist of mathematical operation methods, and northing more import math Return input('Write what do you want to do? \n') You must write minimum 2 numbers')ĭialog.py This is module who provide communication with user by input or output some console messages. Print("You can't write zero, because ist provide an error") Result(operations.tan(get_one_variable())) Result(operations.sin(get_one_variable())) Result(operations.square(get_one_variable())) Result(operations.exponent(get_one_variable())) Result(operations.divide(get_many_variables())) Result(operations.multiply(get_many_variables())) Result(operations.subtract(get_many_variables())) Result(operations.addition(get_many_variables())) It is module where I hold methods for communication my modules, something like middleware (if I may say so) import dialog Entry point of my calculator where i just call run() method from conductor.py module. I don't know is I do it right and how do my code cleaner.
0 Comments
Leave a Reply. |