Can anyone help me with this RETURN question ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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)

22nd Sep 2022, 5:44 AM
Alejandro Cuautle Martinez
Alejandro Cuautle Martinez  - avatar
5 Answers
+ 7
You output no value. Write print(sqrt(4)) to print the value returned by the function.
22nd Sep 2022, 5:47 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 4
# not 🙅 return, but print() def sqrt(value): print(value ** (1/2)) sqrt(4)
22nd Sep 2022, 6:09 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 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.
22nd Sep 2022, 7:08 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 1
22nd Sep 2022, 10:12 PM
Alejandro Cuautle Martinez
Alejandro Cuautle Martinez  - avatar
0
If you need to show something is return we use print()
23rd Sep 2022, 11:19 AM
Oussama Harmouche
Oussama Harmouche - avatar