Jump to content

hi

 

i recently finished my first project, i basic two number calculator and wanted to know what you think, where i could improve, etc.

 

https://www.dropbox.com/s/g6rcxpyi8p7d1cs/calculator.py (it wouldn't let me upload it here)

 

i could add more thing to info but meh

 

thanks

Link to comment
https://linustechtips.com/topic/56763-what-do-you-think/
Share on other sites

Link to post
Share on other sites

It's a good start. What you should do next is look for places where the same code is used and see if you can factor then out. For example the same code is used to get the two numbers used. You could factor this out into a function, which you call to get both numbers

 

Here's a concrete example:

def get_number(message):    while True:        try:            number = float(input(message));            return number        except ValueError:            print("Not valid, try again")first_number = get_number("Enter the first number")second_number = get_number("Enter the second number")
Link to comment
https://linustechtips.com/topic/56763-what-do-you-think/#findComment-768602
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×