0

Python 'def' Function

I think I know what this is but every time I try it out, it doesn't work. (Not talking about any specific code) Can someone help define the function. (See what I did there😒)

19th Feb 2017, 12:10 PM
DerpyOmnister
DerpyOmnister - avatar
2 Answers
+ 2
A function is a block of organized, reusable code that is used to perform a single, related action. Example we define a function here add function that will add a + b and then print theyr sum. def add(a,b): print(a + b) Now we just call that function by its name with a and b variables. add(2,2) š and thats it, we just simplify the code so we dont have to write every time the seme code over and over....i hope this helps
19th Feb 2017, 12:29 PM
Roman Mazal
Roman Mazal - avatar
+ 1
Thx! :)
19th Feb 2017, 1:33 PM
DerpyOmnister
DerpyOmnister - avatar