0
Can someone review this and tell me if its correct?
16 Respuestas
+ 6
Why you passed a parameter and argument ,when Len inch is already defined inside function?🤔
+ 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
+ 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
+ 2
Why are you giving 2*2.54 as an argument to inch to centimetre function , shudn't it be just 2?
+ 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
+ 1
There changed it like I said I'm still learning so I'm making mistakes but learning by them
+ 1
👍
+ 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 ,
+ 1
Hello John Perez check my code, I hope help you.
https://code.sololearn.com/cw4DRPRIhMjd/?ref=app
+ 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.
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?
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
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?
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.
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?
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.