0

Python

I don’t really understand how to use the def function.can someone please explain it?

12th Apr 2022, 5:23 PM
2 ответов
12th Apr 2022, 5:38 PM
Lothar
Lothar - avatar
+ 4
it is used to define a function, it consists of a piece of code which is designed for completing a certain task def yourFunctionName(parameters or Arguments): # your piece of code, written by you reason behind using a function it makes our code reusable, because we can call a function from anywhere in our code, it reduces code length, because we don't have to write same piece of code again and again for example def sumTwoNumbers( first, second ): sum = first + second now we can call this function any number of times we want like, print(sumTwoNumbers ( 10, 20)) print(sumTwoNumbers (1000, 3000)
12th Apr 2022, 5:34 PM
NonStop CODING
NonStop CODING - avatar