What a function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What a function

huh

16th Feb 2019, 11:41 PM
priya vadgama
priya vadgama - avatar
11 Answers
+ 13
A function is a block of code that can be called multiple times.. For instance, you have a function that will add 2 numbers.. Def add(x,y): return x+y Now I can call the add() function and give it 2 numbers. It will return them as many times as I want, instead of having to code it over and over.. print(add(3,5)) print(add(8,5)) print(add(2,4)) Output: 8 13 6
16th Feb 2019, 11:50 PM
LordHill
LordHill - avatar
+ 6
Oh you mean what is a function? Love the huh tag. See answer by Amanda Wertz .
17th Feb 2019, 6:50 AM
Sonic
Sonic - avatar
+ 3
Function is a block of code
17th Feb 2019, 5:55 AM
Mihir Dasani
+ 2
Can you give me an example like a piece of code
16th Feb 2019, 11:50 PM
priya vadgama
priya vadgama - avatar
+ 2
I know all this answers are complicated....😂 Just remeber....fuction is any constant block or part of code which may or may not accept any value for performing a certain task when it is called in the main fuction.... I think you understant now
17th Feb 2019, 1:58 PM
Sanchay Kumar
Sanchay Kumar - avatar
+ 1
also called subroutines or procedures. Functions are used to utilize code in more than one place in a program. The only way without functions to reuse code consists in copying the code so instead of copying code lots of times to do something, we write the function and just tell it to work lots of times. say you had one that turns all letters to CAPITALS anytime you want to do that you tell that function to do so. can throw loads of letters at it from anywhere in the program as the functions programmed to handle it
16th Feb 2019, 11:48 PM
peter
peter - avatar
+ 1
Ohhh thx ok
16th Feb 2019, 11:52 PM
priya vadgama
priya vadgama - avatar
+ 1
Amanda Wertz answer very well and complete
17th Feb 2019, 8:24 AM
amirreza shamsdanesh
amirreza shamsdanesh - avatar
+ 1
A function is a working flow, how the system will work, how the coding will perform on user needs.
17th Feb 2019, 8:56 AM
Kamal Hossan
Kamal Hossan - avatar
+ 1
Thx
17th Feb 2019, 9:19 AM
priya vadgama
priya vadgama - avatar
+ 1
Yeah I kinda do thank you anyway 😂😂
17th Feb 2019, 9:46 PM
priya vadgama
priya vadgama - avatar