Can anyone help me with this RETURN question ? | Sololearn: Learn to code for FREE!

+1

Can anyone help me with this RETURN question ?

I’m practicing RETURN, when i try with this code I get No Output, and I should get 2, is anything wrong with it? def sqrt(value): return value ** (1/2) sqrt(4)

9/22/2022 5:44:17 AM

Alejandro Cuautle Martinez

6 Answers

New Answer

+7

( edit ): wrong tag i want to tag Alejandro Cuautle Martinez but by mistake i tagged 🍇 Alex Tușinean 💜 ) Either you can use 1st method or 2nd method: 1st method: def sqrt(value): print(value ** (1/2)) # no return statement sqrt(4) # but here only we call the function 2nd method: def sqrt(value): return value ** (1/2) # using return statement print(sqrt(4)) # but here we use print function with calling sqrt function

+7

You output no value. Write print(sqrt(4)) to print the value returned by the function.

+4

# not 🙅 return, but print() def sqrt(value): print(value ** (1/2)) sqrt(4)

+3

Yeah but with the first method the range of use for that function is smaller than in the second method. #1 is a function that prints the value while #2 can be used in different formulas which don't necesarily need to be printed.

+1

Now it’s clear, thanks a lot 🧚Somya🌹 ,🍇 Alex Tușinean 💜 ,Yaroslav Vernigora

0

If you need to show something is return we use print()