0
Trying to create a function to perform simple arithmetic, when inputs are entered
5 ответов
0
Your question is incomplete and also your code..
What are you expecting from this code? And what's your error?
0
I'm trying to create a function so it will take inputs and perform a formula and then produce an answer
0
d= int(input('enter distance in km here:'))
t=float(input('enter thickness here in meters'))
def loss(fd, ft):
db_km= (fd*1.5)
db_m= (ft*90)
unknown=5 #you are not defined this define first then use
lossr= ((db_km + db_m)*unknown)
return lossr
print(loss(d,t)) #call the function to use it like this
#read comments then you can understand changes, I hope.
0
What does the f in (fd,ft) do ir what is it for, thanks for the help
0
Just to make sure, they are different from global variables d, t as fd, ft.
If you not use separate variables then global are used and make change in globals, then if you have multiple times usage then you may get wrong results..
Try with your code as
print(loss(d, t) ) #and again
print( loss(d, t) )
Both results different values..
Also your function name is loss and a variable you defined in function also loss. So to not confuse, use different names..
You're welcome...