+ 1

Can somebody explain def functions and related things And a example

27th Dec 2016, 1:52 AM
Nate
3 Antworten
+ 1
Thank you and gor coding large scale things is this required.
27th Dec 2016, 2:49 PM
Nate
0
Python comes with several pre-defined functions. Usually during the development process, you will be creating your own for whatever use you require them for. All 'def' does is defines a new function. Consider it a shorthanded notation of 'definition'. Once you define a function, you give it a name. So let's say: def newfunc(): [Remember that the parentheses are mandatory] Now, you need to decide what you want the function to do. Let's say we want the function to print out "spam" (pretty standard), in that case we add: def newfunc(): print("spam") Finally, in order to execute this code in our project we simply call on the function as such: newfunc()
27th Dec 2016, 1:21 PM
zxcv
0
def name(): print("lalala") name Output: lalala
6th Feb 2017, 5:41 PM
Олег Гричина
Олег Гричина - avatar