Plis help. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Plis help.

what does returning from a function actually meant. elaborate with examples

16th Jan 2017, 7:31 PM
stephen haokip
stephen haokip - avatar
2 Respostas
+ 1
When you create a typical function you would generally say if it'll return something or will it simple just do something. If a function returns something then we can store that something in something else like a variable. def give_back(num): return num var = give_back(3) Our variable that goes by the name "var" now has the value of 3. Our function gave back to us, it's *fruitful*. def print_text(text): print(text) print_text("Some text") # Would print to screen: # Some text That function doesn't give back it just...does something. All functions give back something though, *fruitful functions* will return something for us to use, hence *return*. While the other functions are void. They do something but doesn't return a value, well that function actually returns a value of None which is...nothing lol.
17th Jan 2017, 3:42 AM
Don
Don - avatar
0
thats not how you spell please matey xx
17th Jan 2017, 10:52 AM
bob