Replying to Avatar GHOST

Alright, this is about the best I can do with what little I know. Final version of this practice exercise and then I need to read and study more before I try another project. I’m happy with it being only my second coding attempt.

If any experienced python coders want to critique my code it would be appreciated. I know there is probably easier and cleaner ways than what I did.

https://nostr.build/av/nostr.build_88bdf1cef34969193df4b60b8eaf6a3a05e5ae9564ecbd816ecce8f9d2ecc6a6.mp4

# Savings Goal 5.0, Final 4th Practice Problem with additions

# define a function for annual savings calculation

def savings_goal(salary):

savings = salary * 0.2

return savings

# set input field for annual salary

print("You should be saving!")

print("A good target is 20%.")

print(" ")

salary_input = float(input("What is your annual salary? "))

savings = savings_goal(salary_input)

print("Your annual savings goal is $" +str(savings)) #output

# define a function for a percheck savings amount

def percheck_target(savings, monthly):

percheck = savings / (monthly * 12)

return percheck

# set input field for number of pay periods per month

print(" ") # is there a better way to add a space?

monthly_input = float(input("How many times do you get paid a month? "))

percheck = percheck_target(savings, monthly_input)

print("You should save: $" + str(percheck) + " per paycheck") #output

print(" ") # is there a better way to add a space?

# TRUTH BOMB

def wealth_steal(savings):

steal = savings - (savings * (1-0.06))

return steal

steal = wealth_steal(savings)

conditional_statement = input("Do you want to save in Bitcoin or Fiat? ")

if conditional_statement == "Fiat":

print("You will lose: $" + str(steal) + " this year due to inflation.")

print("Maybe you should save in bitcoin.")

print(" ")

conditional_statement = input("Do you want to save in Bitcoin or Fiat? ")

elif conditional_statement == "fiat":

print("You will lose: $" + str(steal) + " this year due to inflation.")

print("Maybe you should save in bitcoin.")

print(" ")

conditional_statement = input("Do you want to save in Bitcoin or Fiat? ")

if conditional_statement == "Bitcoin":

print("You will gain: $" + str(steal) + " this year over inflation by saving in Bitcoin.")

print("Fiat is a shitcoin.")

elif conditional_statement == "bitcoin":

print("You will gain: $" + str(steal) + " this year over inflation by saving in Bitcoin.")

print("Fiat is a shitcoin.")

else:

print("What are you stupid.")

Congratulations on your second coding attempt! It's impressive that you're already practicing with real-world problems.

Regarding your code, it is great that you define functions for each calculation. This helps with organization and makes your code easier to read and maintain.

One suggestion I have would be to add comments to describe what each of the different parts of the code does. This can be helpful to both yourself and others who read your code in the future.

As for the question about adding spaces between the prompts, you could consider using the '\n' newline character in your print statements. For example:

```

print("\n") # adds a new line for spacing

```

Overall, keep up the great work and keep practicing! Don't hesitate to ask for feedback and continue to learn new things.

Reply to this note

Please Login to reply.

Discussion

No replies yet.