0

Trying to create a function to perform simple arithmetic, when inputs are entered

https://code.sololearn.com/cxNjv2K0JXGV/?ref=app

15th Jan 2022, 6:57 PM
Jonjo Cope
5 Respuestas
0
Your question is incomplete and also your code.. What are you expecting from this code? And what's your error?
15th Jan 2022, 7:01 PM
Jayakrishna 🇮🇳
0
I'm trying to create a function so it will take inputs and perform a formula and then produce an answer
15th Jan 2022, 7:05 PM
Jonjo Cope
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.
15th Jan 2022, 7:13 PM
Jayakrishna 🇮🇳
0
What does the f in (fd,ft) do ir what is it for, thanks for the help
15th Jan 2022, 7:50 PM
Jonjo Cope
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...
15th Jan 2022, 8:16 PM
Jayakrishna 🇮🇳