Saturday 15 January 2011

python - Invalid Syntax (Strings and Float complications!) -



python - Invalid Syntax (Strings and Float complications!) -

i can't seem figure out. help appreciated.

pitcherspeed=float(round((40908/tempspeed),2)) output=output+temppitcher+ "\t" +str(round(float(tempspeed), 2)) + "\t" +str(round(float(pitcherspeed), 2)) +"\n"

i having issues above 2 lines. no matter alter them. error out. need help determining heck wrong them!

here of code (if needed):

output="" pitcherspeed=1 temppitcher=input("enter name of next contestant, or nil exit: ") fastestspeed=0 slowestspeed=0 if temppitcher=="": exit() fastestpitcher=temppitcher slowestpitcher=temppitcher tempspeed=float(input("enter time " +str(temppitcher) + "'s speed in milliseconds: ")) fastestspeed=tempspeed slowestspeed=tempspeed while temppitcher!="": output="" temppitcher=input("enter name of next contestant, or nil exit: ") tempspeed=input("enter time " +str(temppitcher) + "'s speed in milliseconds: ") pitcherspeed=float(round((40908/tempspeed),2)) output=output+temppitcher+ "\t" +str(round(float(tempspeed), 2)) + "\t" +str(round(float(pitcherspeed), 2)) +"\n" if temppitcher!="": tempspeed=input("enter time " +str(temppitcher) + "'s speed in milliseconds: ") if tempspeed==fastestspeed: fastestspeed=tempspeed fastestpitcher=temppitcher if tempspeed==slowestspeed: slowestspeed=tempspeed slowestpitcher=temppitcher print("name" + "\t" +"time" +"\t" +"speed" + "\n" + "===========================" + "\n") print(output) print("slowest pitcher " +str(slowestpitcher) +"at" +str(slowestspeed) +"miles per hour") print("fastest pitcher " +str(fastestpitcher) +"at" +str(slowestspeed) +"miles per hour")

i receive error message: traceback (most recent phone call last): file "c:/users/whitney.meulink/desktop/programpractice.py", line 17, in pitcherspeed=float(round((40908/tempspeed),2)) typeerror: unsupported operand type(s) /: 'int' , 'str'

the line:

pitcherspeed=float(round((40908/tempspeed),2)

is missing closing bracket.

pitcherspeed=float(round((40908/tempspeed),2))

it case error on previous line.

python

No comments:

Post a Comment