Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Needs to Be a Bit Shorter #32

Closed
rudrathegreat opened this issue Apr 3, 2018 · 5 comments
Closed

Code Needs to Be a Bit Shorter #32

rudrathegreat opened this issue Apr 3, 2018 · 5 comments

Comments

@rudrathegreat
Copy link

rudrathegreat commented Apr 3, 2018

Your code is great but could you make it a bit shorter. You can add methods with parameters 'sign', 'num1' and 'num2'

def add(num1 = None, num2 = None):
    answer = num1 + num2
    print(answer) # You can also do 'return answer'
@elsilentforce
Copy link

I guess this is not the best way to solve the problem, for me, the calculator is doing it's job very well.

@rudrathegreat
Copy link
Author

rudrathegreat commented Jul 12, 2018

If you think the existing code is relevant, that is fine. There can be more functionality and you can simply add functionality by import 'math'.

import math

math.sqrt(num)

Plus the existing code has limitations, only going up to an extent. If you want a calculator that can give you answers to questions involving big numbers, then you can cut down the code a lot and add new functionality in the lines he has already used. Simply -

import math

def add(num1 = None, num2 = None):
    answer = num1 + num2
    return answer

def subtract(num1 = None, num2 = None):
    answer = num1 - num2
    return answer

def multiply(num1 = None, num2 = None):
    answer = num1 * num2
    return answer

def divide(num1 = None, num2 = None):
    answer = num1/num2
    return answer

# And so on

And plus he can add a GUI to his program using Tkinter.

What's more is that you can use NumPy for certain operations as well

@nithilan4
Copy link

I really like how he's doing it, I don't think it needs to be changed...

@rudrathegreat
Copy link
Author

rudrathegreat commented Nov 28, 2018

As @AceLewis points out -

Read the readme and you may get some context. This is not supposed to be good code it is literally a joke.

And as @elsilentforce says -

I guess this is not the best way to solve the problem, for me, the calculator is doing it's job very well.

Plus most of the issues here are not really issues but a bunch of funny conversations. As @v1993 comments -

Just for lulz probably

And most people are now saying that if this code is ever going to change or be optimised, then the best way is to make functions and calling them whenever you want. -

Put a calculator in a function to call this function again when the code ends - @Artaman

And many people are saying that the code is crashing their browsers -

I haet u. u crashed my browser - @TheInitializer
Same issue here - @ahmedouvic

So this why I think that -

  1. This is the best way to increase efficiency of the code
  2. Add more functionality without crashing anybody browsers

😄

@rudrathegreat
Copy link
Author

I think this issue has already had a satisfying answer, that the my_first_calculator.py code was generated by another piece of code called generator.py. So, I am going to be closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants