python formulas returning 0s

Question:

so I have basic formulas setup to recive numbers and then covert them but when running the program the converted formulas aren’t calculating

dollars = 0
pounds = 0
tempF = 0
tempC = 0
globe = "U0001F30D"


euros = dollars*.95
kilograms = pounds/2.2
tempF = tempC* 9/5+32 


print ("How many U.S dollars can you afford to spend on your trip?: ")
dollars = float(input())

print("How many pounds of chocoloate will you be buying?:")
pounds = float(input())

print("What is the tempature in degrees Celsius on the European news?:")
tempC = float(input())



print ("ITINERARY NOTES")
print ("------------------------------------------------------")

print (globe + " you have {:.2f} euros to spend." .format(euros))
print (globe + " Plan to buy {:.2f} of chocolate for family and friends".format(kilograms))
print (globe + " The tempature in Europe is {} degrees F, So dress appropriately.".format(tempF))
How many U.S dollars can you afford to spend on your trip?: 
100 
How many pounds of chocoloate will you be buying?:
5
What is the tempature in degrees Celsius on the European news?:
15

ITINERARY NOTES
------------------------------------------------------
  you have 0.00 euros to spend.
  Plan to buy 0.00 of chocolate for family and friends
  The temperature in Europe is 32.0 degrees F, So dress appropriately.
Asked By: Don Beedrill

||

Answers:

Try calculating the results after you input the data, not before that

Answered By: Antony Hatchkins

How I would do it

def get_input():
    print ("How many U.S dollars can you afford to spend on your trip?: ")
    dollars = float(input())

    print("How many pounds of chocoloate will you be buying?:")
    pounds = float(input())

    print("What is the tempature in degrees Celsius on the European news?:")
    tempC = float(input())
    return [dollars, pounds, tempC]

def dollars_to_euros(dollars):
    return 0.95 * dollars

def pounds_to_kilograms(pounds):
    return pounds / 2.2

def tempC_to_tempF(tempC):
    return tempC * 9 / 5 + 32

globe = "U0001F30D"

[dollars, pounds, tempC] = get_input()

#move formula calculation after receiving the input
euros = dollars_to_euros(dollars)
kilograms = pounds_to_kilograms(pounds)
tempF = tempC_to_tempF(tempC)


print ("ITINERARY NOTES")
print ("------------------------------------------------------")

print (globe + " you have {:.2f} euros to spend." .format(euros))
print (globe + " Plan to buy {:.2f} of chocolate for family and friends".format(kilograms))
print (globe + " The tempature in Europe is {} degrees F, So dress appropriately.".format(tempF))

Minimal changes to your existing snippet to make it work:

dollars = 0
pounds = 0
tempF = 0
tempC = 0
globe = "U0001F30D"


print ("How many U.S dollars can you afford to spend on your trip?: ")
dollars = float(input())

print("How many pounds of chocoloate will you be buying?:")
pounds = float(input())

print("What is the tempature in degrees Celsius on the European news?:")
tempC = float(input())

#move formula calculation after receiving the input
euros = dollars*.95
kilograms = pounds/2.2
tempF = tempC* 9/5+32 


print ("ITINERARY NOTES")
print ("------------------------------------------------------")

print (globe + " you have {:.2f} euros to spend." .format(euros))
print (globe + " Plan to buy {:.2f} of chocolate for family and friends".format(kilograms))
print (globe + " The tempature in Europe is {} degrees F, So dress appropriately.".format(tempF))
Answered By: heiheihang
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.