Ask coding questions

← Back to all posts
Speed, Distance, Time
OldWizard209

Hi, I ma a beginner and I was making this program which was going to give you the speed if you enter the distance and time and it was going to give you the time if you entered the distance speed. I am a beginner in Python. I have posted the code. Please check it and see the error and tell me how to fix it. This is the code https://repl.it/@abdullahrajput9/SpeedTime#main.py and this is the error:

And BTW I have just made the Speed finding code. Soo, when the program runs you have to enter the number 1 and then you can proceed. Thanks for helping :)

Answered by SUHASTADIPARTH1 [earned 5 cycles]
View Answer
Voters
SUHASTADIPARTH1
OldWizard209
Comments
hotnewtop
SUHASTADIPARTH1

This is how you do the speed formula in python:

OldWizard209

Thanks @SUHASTADIPARTH1 It fixed my code Thanks A LOT MAN

SUHASTADIPARTH1

@abdullahrajput9 No problem :)

RYANTADIPARTHI

use int in your code

so they need to be ints

OldWizard209

Thanks a LOT for the help :) @RYANTADIPARTHI

RYANTADIPARTHI

@abdullahrajput9 np, can you please mark my answer? Thanks!

OldWizard209

UMM Actually someone answered first and I marked him, I don't
think I can mark again. I tried but it didn't work. Really Sorry @RYANTADIPARTHI

OldWizard209

But you can always have an upvote @RYANTADIPARTHI

RYANTADIPARTHI
RYANTADIPARTHI
OldWizard209
RYANTADIPARTHI

@abdullahrajput9 it's np, at least i got an upvote right? :)

OldWizard209

More than 1 upvote LOL (Not taking credit BTW) @RYANTADIPARTHI

RYANTADIPARTHI

@abdullahrajput9 yeah, thx!!

RYANTADIPARTHI

@abdullahrajput9 could you explain the last part a bit better? thx

zplusfour

@RYANTADIPARTHI cycle farming, replit cycles aren't youtube likes

OldWizard209

Umm NVM @RYANTADIPARTHI Just thanks for the help :)

RYANTADIPARTHI
OldWizard209

Not advertising guys but this is the final version of what I was planning to make https://repl.it/talk/share/Speed-Distance-Time-Finder/60420 ((Thanks to you all)) Not looking for upvotes either :)

RYANTADIPARTHI
Muffinlavania

The error says
unsupported operator type(s) for / : str and str
This is saying that the two 'numbers' are actually phrases! (Example: It is '2' instead of 2) So to convert them you have to use int(), like this

And then the formula should work?

OldWizard209

Thank you SOOOOOOOOO MUCH @Muffinlavania It fixed my code. Thanks a lot

Muffinlavania

@abdullahrajput9 yeeeeeeeeee

OldWizard209

Not advertising guys but this is the final version of what I was planning to make https://repl.it/talk/share/Speed-Distance-Time-Finder/60420 ((Thanks to you all)) Not looking for upvotes either :)

SUHASTADIPARTH1

You have that error, you have to convert those numbers (which are strings by default) to integers by doing int() and the number or variable inside those brackets.

OldWizard209

Not advertising guys but this is the final version of what I was planning to make https://repl.it/talk/share/Speed-Distance-Time-Finder/60420 ((Thanks to you all)) Not looking for upvotes either :)