为什么我的Python脚本不能工作?

时间:2017-05-18 05:23:20

标签: python-3.x scripting

这个脚本不会print()我想要它,这是单独的成本,总成本和剩余资金。请以这种特殊的方式帮助解释它为什么会出现故障。谢谢。 (很长一段时间以来,我已经多次尝试过这种方式,所以非常感谢你的帮助。)

i = input
p = print
f = float
I = int
s = str
shelf = {}

def finalFunction2():
    try:
        shelf['3'] = ((float(shelf['5.5']))/(float(shelf['4.5']))) * (float(shelf['3.5']))
        print("Budget: " + str(shelf['1.5']))
        print(shelf['2'])
        print("Gas cost: " + str(shelf['3.5']))
        print(shelf['6'])
        print(shelf['7'])
        print(shelf['8'])
        totalCost = (shelf['3.5']) + (shelf['5.5']) + (shelf['6.5']) + (shelf['7.5'])
        print("Total cost: " + str(totalCost))
        leftOver = float(shelf['1.5']) - totalCost
        print("Left over: " + str(leftOver))
    except ValueError:
        print("Error.")

def finalFunction1(Info, fN, ID):
    Info2 = str(Info)
    shelf[fN] = ID + Info2
    shelf[fN + ".5"] = Info
    Info = float(Info)

def finalFunction1p5(Info, fN):
    Info2 = str(Info)
    shelf[fN] = Info2
    shelf[fN + ".5"] = Info
    Info = float(Info)

def getFinalFunction():
    finalFunction2()

def startCalculator():
    Budget = i("What is your budget?")
    getBudget(Budget)

def getBudget(Budget):
    try:
        fN = str(1)
        Budget = float(Budget)
        Destination = i("What is your destination?")
        finalFunction1p5(Budget, fN)
        getDestination(Destination)
    except ValueError:
        print("Please enter a numerical character.")
        startCalculator()

def getDestination(Destination):
    try:
       fN = str(2)
       Destination = str(Destination)
       ID = "Destination: "
       Gas = input("What is your cost of gas?")
       finalFunction1(Destination, fN, ID)
       getGas(Gas)
    except ValueError:
      print("Please enter a numerical character.")
        getBudget(shelf['1.5'])

def getGas(Gas):
    try:
        fN = str(3)
        Gas = float(Gas)
        MPG = i("How many mile per gallon does your car get?")
        finalFunction1p5(Gas, fN)
        getMPG(MPG)
    except ValueError:
        print("Please enter a numerical character.")
        getDestination(shelf['2.5'])

def getMPG(MPG):
    try:
        fN = str(4)
        MPG = float(MPG)
        Distance = i("What is the total amount of distance you expect to travel?")
        finalFunction1p5(MPG, fN)
        getDistance(Distance)
    except ValueError:
        print("Please enter a numerical character.")
        getGas(shelf['3.5'])

def getDistance(Distance):
    try:
        fN = str(5)
        Distance = float(Distance)
        Food = i("What amount of money do you intend to spend on food?")
        finalFunction1p5(Distance, fN)
        getFood(Food)
    except ValueError:
        print("Please enter a numerical character.")
        getMPG(shelf['4.5'])

def getFood(Food):
    try:
        fN = str(6)
        ID = "Food cost: "
        Food = float(Food)
        Accommadations = i("How much money do you intend to spend on accommadations?")
        finalFunction1(Food, fN, ID)
        getAccommadations(Accommadations)
    except ValueError:
        print("Please enter a numerical character.")
        getMPG(shelf['5.5'])

def getAccommadations(Accommadations):
    try:
        fN = str(7)
        ID = "Accommadation cost: "
        Accommadations = float(Accommadations)
        Plans = i("How much money do you intend to spend on recreational or 
leisurely activities?")
        finalFunction1(Accommadations, fN, ID)
        getPlans(Plans)
    except ValueError:
        print("Please enter a numerical character.")
        getFood(shelf['6.5'])

def getPlans(Plans):
    try:
        Plans = float(Plans)
        fN = str(8)
        ID = "Plans cost: "
        finalFunction1(Plans, fN, ID)
        getFinalFunction()
    except ValueError:
        print("Please enter a numerical character.")
        getAccommadations(shelf['7.5'])

startCalculator()

0 个答案:

没有答案