Nov-10-2017, 04:36 PM
(This post was last modified: Nov-10-2017, 08:51 PM by sparkz_alot.)
(Nov-09-2017, 08:35 AM)Mekire Wrote: The problem here is you never defined these three variablesNever defined them? I'm getting their values through user input, so how is that not defining them?monthlyInvestment, yearlyInterest, yearswhen you pass them tocalculateFutureValueon line 15. As it seems you want to take those from user input, you don't need to pass them at all.
Also, here is more more trouble I'm having with my functions (the questions and errors are in the code comments):
#!/usr/bin/env python3
#MainFunctionBasics.py
def globalVarExperiment(distancePerMinute, distancePerSecond):
distancePerMinute = hyperSonicSpeed / 60
distancePerSecond = hyperSonicSpeed / 3600
print("At " + hyperSonicSpeed + "mph, you travel:")
print(distancePerMinute + "miles per minute, and "
+ distancePerSecond + "miles per second.")
global hyperSonicSpeed = 4000#Um... why is the = sign invalid syntax here?
def main():
globalVarExperiment()
print()
yearlySalary = hardCodedNamedArguments(wage, workWeek)#wage is not defined
print()
milesPerMinute = overrideValues(200,60)#how do I override the arguments?
print()
#main function definition ends here
def hardCodedNamedArguments(hourlyWage=62.5, weeklyWorkHours=40):
weeklyPaycheck = weeklyWorkHours * weeklyWorkHours
monthlyPaycheck = 4 * weeklyPaycheck
yearlySalary = monthlyPaycheck * 12
return yearlySalary
def overrideValues(500, 60):#500 is invalid syntax. Why?
milesPerMinute = 500 / 60
print("At " + 500 + "mph, you travel " + milesPerMinute
+ " miles per minute.")
return milesPerMinute
main()
