1 00:00:00,000 --> 00:00:07,000 And let's do some exercises to practice on what you have seen in this section and also 2 00:00:07,001 --> 00:00:10,050 combined with the last section. So we are going to 3 00:00:10,062 --> 00:00:13,000 practice mostly on functions here, okay? And you 4 00:00:13,001 --> 00:00:16,989 will have four different exercises. So the first 5 00:00:17,001 --> 00:00:21,000 three exercises are actually the same as for the 6 00:00:21,001 --> 00:00:24,489 last section, but this time you are going to use 7 00:00:24,501 --> 00:00:28,000 functions, okay? So the functionalities that you 8 00:00:28,001 --> 00:00:31,382 have previously implemented in the Python shell, 9 00:00:31,394 --> 00:00:35,000 you are going to write code inside PyCharm. So what 10 00:00:35,001 --> 00:00:37,958 you can do is you can create a new file for each 11 00:00:37,970 --> 00:00:41,000 program. So I'm going to show you how to do that. 12 00:00:41,001 --> 00:00:43,958 Okay, very quickly how you can create a new file 13 00:00:43,970 --> 00:00:47,000 for each exercise so you can better organize your 14 00:00:47,001 --> 00:00:51,031 code. So you are still in your project here. You 15 00:00:51,043 --> 00:00:55,000 can right click new Python file, okay? And just 16 00:00:55,001 --> 00:00:57,927 name your file. So for example, test, okay? This 17 00:00:57,939 --> 00:01:01,000 is a Python file. I press enter and you have a new 18 00:01:01,001 --> 00:01:04,946 test.py. So make sure you have the py extension 19 00:01:04,958 --> 00:01:09,000 here. So now you have main.py, test.py. I'm just 20 00:01:09,001 --> 00:01:14,433 going to write print hello from test, okay? Press 21 00:01:14,445 --> 00:01:20,000 Ctrl+S or Command+S to save the file. And now what 22 00:01:20,001 --> 00:01:22,989 you can do, so you can click on run here. And by 23 00:01:23,001 --> 00:01:26,000 default it's going to run the main, okay? As you 24 00:01:26,001 --> 00:01:29,021 can see here, it's going to run main.py. If you 25 00:01:29,033 --> 00:01:32,000 want to run test.py, you can click on run with 26 00:01:32,001 --> 00:01:35,946 dot, dot, dot. And you can choose the file test 27 00:01:35,958 --> 00:01:40,000 here. And it's going to run test. So you can see 28 00:01:40,001 --> 00:01:43,019 hello from test. And then you can choose here, you 29 00:01:43,031 --> 00:01:46,000 can toggle between main and test. So if you click 30 00:01:46,001 --> 00:01:49,419 on main, it's going to run the main file. Test is 31 00:01:49,431 --> 00:01:53,000 going to run test file. So you can create different 32 00:01:53,001 --> 00:01:56,489 files and you can toggle here. Make sure you add 33 00:01:56,501 --> 00:02:00,000 them with the run dot, dot, dot here. All right. 34 00:02:00,001 --> 00:02:04,346 And if you want to remove a file, simply right 35 00:02:04,358 --> 00:02:09,000 click, delete. Are you sure? Okay. And so you can 36 00:02:09,001 --> 00:02:11,956 add one file per exercise, okay? So the first 37 00:02:11,968 --> 00:02:15,000 exercise you are going to ask for the name and 38 00:02:15,001 --> 00:02:17,929 age of the user and print the info. This actually 39 00:02:17,941 --> 00:02:21,000 is what we have done to explain the functions here. 40 00:02:21,001 --> 00:02:23,461 So this is already done, but as an additional 41 00:02:23,473 --> 00:02:26,000 practice, you can just start with a blank page 42 00:02:26,001 --> 00:02:32,000 and rewrite that function, okay? As a first practice. And then, so ask the user for two 43 00:02:32,001 --> 00:02:35,525 integer numbers, add them and print them with the 44 00:02:35,537 --> 00:02:39,000 result. So you can create here a function to add 45 00:02:39,001 --> 00:02:41,544 two numbers and return the value. And then you 46 00:02:41,556 --> 00:02:44,000 can print the result. And for the third one, 47 00:02:44,001 --> 00:02:47,020 create a list of four float numbers, compute the 48 00:02:47,032 --> 00:02:50,000 average and print it. You can create a function 49 00:02:50,001 --> 00:02:53,563 here that is going to compute the average of any 50 00:02:53,575 --> 00:02:57,000 list of numbers. Okay? So you're going to call 51 00:02:57,001 --> 00:03:00,417 this function and print the result. So those are 52 00:03:00,429 --> 00:03:04,000 the three first exercises. And then the fourth one 53 00:03:04,001 --> 00:03:06,517 is a new exercise. You are going to create a 54 00:03:06,529 --> 00:03:09,000 function to convert from Celsius degrees to 55 00:03:09,001 --> 00:03:11,989 Fahrenheit degrees. Okay? You have the formula 56 00:03:12,001 --> 00:03:15,000 here. So you have Celsius degrees. You need to 57 00:03:15,001 --> 00:03:20,295 multiply Celsius by 1.8 and add 32 to get Fahrenheit 58 00:03:20,307 --> 00:03:25,000 degrees. Okay. So for each of those exercises, 59 00:03:25,001 --> 00:03:27,956 one of the challenges also will be how you can 60 00:03:27,968 --> 00:03:31,000 name the function, okay? Naming the function is 61 00:03:31,001 --> 00:03:33,545 very important to give a meaningful name. And 62 00:03:33,557 --> 00:03:36,000 then how you are going to organize the code 63 00:03:36,001 --> 00:03:39,021 to make it work. All right. So now if you still 64 00:03:39,033 --> 00:03:42,000 have some trouble understanding some concepts, 65 00:03:42,001 --> 00:03:44,462 please go back to the previous lessons to watch 66 00:03:44,474 --> 00:03:50,000 them again. And I will see you in the next video for the solution of the exercises.