0

Can someone review this and tell me if its correct?

Coding https://code.sololearn.com/cCNd1hKZn82B/?ref=app

27th May 2020, 5:49 PM
John Perez
John Perez - avatar
16 Answers
+ 6
Why you passed a parameter and argument ,when Len inch is already defined inside function?đŸ€”
27th May 2020, 5:52 PM
Abhay
Abhay - avatar
+ 5
Shouldn't it be like this? def inch_to_centimeter(len_inch): return len_inch * 2.54 print(inch_to_centimeter(2)) 2 is the no.of inches you pass to function and converts it into centimetres and returns the value
27th May 2020, 6:12 PM
Abhay
Abhay - avatar
+ 3
Check this out Using the little i have learnt and this is what I came up with: https://code.sololearn.com/cVYaAb5iEOnf/?ref=app
29th May 2020, 11:54 AM
Andazi
Andazi - avatar
+ 2
Why are you giving 2*2.54 as an argument to inch to centimetre function , shudn't it be just 2?
27th May 2020, 6:02 PM
Abhay
Abhay - avatar
+ 1
But you are already multiplying inches *2.54 inside function ,so why pass 2*2.54 as argument to a function that just needs Len of inches to convert it into centimeter
27th May 2020, 6:07 PM
Abhay
Abhay - avatar
+ 1
There changed it like I said I'm still learning so I'm making mistakes but learning by them
27th May 2020, 6:10 PM
John Perez
John Perez - avatar
+ 1
👍
27th May 2020, 6:12 PM
Abhay
Abhay - avatar
+ 1
def inch_to_centimeter(len_inch): return 2 * 2.54 print(inch_to_centimeter(2 * 2.54)) Why are you passing len_inch as parameter and argument as 2*2.54 in it ? You don't use len_inch inside function so no use of parameter here ,you are instead directly returning 2*2.54 ,
27th May 2020, 6:18 PM
Abhay
Abhay - avatar
+ 1
Hello John Perez check my code, I hope help you. https://code.sololearn.com/cw4DRPRIhMjd/?ref=app
27th May 2020, 7:01 PM
Josshual A. Toro M.
Josshual A. Toro M. - avatar
+ 1
Thank you Jossh, that helps me alot too I'm still learning but I'll take this and use them as examples as well.
27th May 2020, 7:23 PM
John Perez
John Perez - avatar
0
Cause it gave me two different answers and I wanted to get some input if it was correct as an exception since it worked lol I fixed it now can you review it again and tell me if it makes more sense?
27th May 2020, 5:56 PM
John Perez
John Perez - avatar
0
Awsome thank you I'm sort of new still and learning so I'm just doing simple things atm but I want to be a red team member and just building my way up anyway I can
27th May 2020, 6:01 PM
John Perez
John Perez - avatar
0
Because when I looked up the formula for inches to Centimeters conversion it says to multiply the length of the inches by the value 2.54 is that not correct or applicable?
27th May 2020, 6:05 PM
John Perez
John Perez - avatar
0
Oh sorry I misunderstood your question no I was just looking at it now yeah you're right idk actually so instead of putting len_inches for line 2 I can just put 2 instead.
27th May 2020, 6:08 PM
John Perez
John Perez - avatar
0
If it gives the same out put I got with mine then sure I'll try it too. I'm trying to make it look clean and as concise as possible. Is there a difference between the two?
27th May 2020, 6:15 PM
John Perez
John Perez - avatar
0
Ah I see what you mean, yeah you're right it doesnt make sense to do it that way. Idk I suppose it looked okay to me. Question though about the len_inch parameter on line one. I dont have to define or assign a variable to it i.e. len_inch = num right? Why is that? Is it because the len_inch is already being defined with the inch_to_centimeter? I'm just trying to better understand that portion.
27th May 2020, 6:22 PM
John Perez
John Perez - avatar