WEBVTT

00:00.000 --> 00:05.000
Understanding functions and Python.

00:05.000 --> 00:12.000
We'll exploring a key concept in programming, function, and by the end, you'll be able to understand

00:12.000 --> 00:17.000
what is a function, working with function.

00:17.000 --> 00:20.000
What is a function?

00:20.000 --> 00:26.000
Function performs a specific operation on it, like 2 plus 2, and then it gives you an output.

00:26.000 --> 00:32.000
4. It's all about transforming inputs into outputs based on set rules.

00:32.000 --> 00:34.000
Advantages.

00:34.000 --> 00:38.000
Efficiency saves time by reusing code.

00:38.000 --> 00:41.000
Organization keeps programs neat.

00:41.000 --> 00:44.000
Simplicity makes fixing code easier.

00:44.000 --> 00:47.000
Defining a function.

00:47.000 --> 00:50.000
Creating a function in Python is easy.

00:50.000 --> 00:54.000
You start by writing the word DEF, then give your function a name.

00:54.000 --> 00:58.000
After the name, add parentheses, and finish with a colon.

00:58.000 --> 01:01.000
Let's create a function that adds two numbers together.

01:01.000 --> 01:08.000
DEF add a, b, consider, a as the age of girl, and b as age of boy.

01:08.000 --> 01:12.000
Return, a plus b.

01:12.000 --> 01:15.000
We use DEF to tell Python we are creating a function.

01:15.000 --> 01:17.000
Add parentheses is the name of our function.

01:17.000 --> 01:23.000
Return, a plus b is output.

01:23.000 --> 01:25.000
Calling a function.

01:25.000 --> 01:29.000
Use the function name with parentheses.

01:29.000 --> 01:32.000
DEF add a, b.

01:32.000 --> 01:34.000
Return a plus b.

01:34.000 --> 01:37.000
Result equal to add 3, 5.

01:37.000 --> 01:39.000
Print result.

01:39.000 --> 01:42.000
Here, add 3, 5.

01:42.000 --> 01:46.000
Calls the function to add the numbers.

01:46.000 --> 01:49.000
Parameters and arguments.

01:49.000 --> 01:56.000
When you ask a function to do something, you often need to provide extra information called a parameter or argument.

01:56.000 --> 02:03.000
Here, 3 and 5 are the arguments that the function uses to calculate the sum.

02:03.000 --> 02:06.000
Returning values from functions.

02:06.000 --> 02:09.000
Here, add 3, 5.

02:09.000 --> 02:13.000
Returns is result 8.

02:13.000 --> 02:16.000
Click run to see the results.

02:17.000 --> 02:21.000
Functions in Python organize your code and make it reusable.

02:21.000 --> 02:26.000
You can create similar functions for different tasks, improving efficiency.

