Share your repls and programming experiences

← Back to all posts
HarveyH (97)

This is my calculator! And yes, I know, percentage, fraction and divide doesn't give the correct answer sometimes. I don't know how to fix that yet... If you could help me or tell me about a bug other then the one mentioned above, that would be great!

WonderNote18 (4)

You could cut down your print statements by using string formatting (ex. var = 'jeff' print('Hello {}!'.format(var)).
In each of your functions for the calculator, you can create functions (def functionName(args): ) for addition, subtraction, etc. for easier readability.
You can run your input check statement (line 45 + every "if a==something") by checking for the name of the string so that way you don't have to assign variables for your options (ex. if a == 'divide': #Division code here)
Use if/elif/else for readability (if (this): do this. elif (that): do that)
For division, you could enclose the assignment of with float() to return the value with decimal numbers.
I'm confused by your fraction function. Do you want to return a fraction of numbers with lowest common denominator, or a fraction of the number in fractal/decimal form?
Either way, a very great program with a lot of depth and potential for growth. Keep it up!

HarveyH (97)

@WonderNote18 Thnxs! I might try to recreate my calculator with examples you have shown. After all, the first version of my calculator was only my second fullyfledge programme, therefore I didn't know as much as I did back then and kinda just stuck with how I did my old calculator.

HarveyH (97)

@HarveyH I think I made the fraction one do the number divided by the denominator, and multiplied by the numerator.