1 00:00:00,000 --> 00:00:03,690 And let's do some exercises to practice on what 2 00:00:03,690 --> 00:00:07,380 you have seen in this section, and also combined 3 00:00:07,410 --> 00:00:10,260 with the last section. So we're going to practice 4 00:00:10,260 --> 00:00:14,010 mostly on functions here, okay, and you will have 5 00:00:14,040 --> 00:00:17,820 four different exercises. So the first three 6 00:00:17,820 --> 00:00:21,090 exercises are actually the same, as for the last 7 00:00:21,120 --> 00:00:23,790 section, but this time, you are going to use 8 00:00:23,850 --> 00:00:27,780 functions, okay? So the functionalities that you 9 00:00:27,780 --> 00:00:31,170 have previously implemented in the Python Shell, 10 00:00:31,350 --> 00:00:34,650 you are going to write code inside PyCharm. So 11 00:00:34,650 --> 00:00:37,710 what you can do is you can create a new file for 12 00:00:37,740 --> 00:00:40,530 each program. So I'm going to show you how to do 13 00:00:40,530 --> 00:00:43,620 that. Okay, very quickly how you can create a new 14 00:00:43,620 --> 00:00:46,950 file for each exercise so you can better organize 15 00:00:46,980 --> 00:00:49,800 your code. So you're still in your project here, 16 00:00:49,800 --> 00:00:54,840 you can right click New, Python File, okay, and 17 00:00:54,840 --> 00:00:57,930 just name your file. So for example, test, okay, 18 00:00:57,930 --> 00:01:01,290 this is a Python file, I press enter, and we have a new 19 00:01:01,290 --> 00:01:05,099 test.py. So make sure you have the .py extension 20 00:01:05,099 --> 00:01:09,510 here. So now you have main.py, test.py. Just going 21 00:01:09,510 --> 00:01:17,010 to write print("Hello from test"), ok, press CTRL S 22 00:01:17,010 --> 00:01:20,250 or Command S to save the file. And now what you 23 00:01:20,250 --> 00:01:23,790 can do so you can click on the Run here, and by 24 00:01:23,790 --> 00:01:26,160 default is going to run the main.py. Okay, as you can 25 00:01:26,160 --> 00:01:28,980 see here, it's going to run main.py. If you want 26 00:01:28,980 --> 00:01:33,361 to run test.py, you can click on a Run with dot dot dot, 27 00:01:33,361 --> 00:01:36,540 and you can choose the file test here. 28 00:01:37,440 --> 00:01:39,960 And it's going to run test, so you can see, Hello 29 00:01:39,960 --> 00:01:42,630 from test. And then you can choose here, you can 30 00:01:42,630 --> 00:01:45,960 toggle between main and test. So if you click on 31 00:01:45,960 --> 00:01:50,100 main is going to run, the main file, test is going 32 00:01:50,100 --> 00:01:53,220 to run test file. So you can treat different files 33 00:01:53,220 --> 00:01:56,490 and you can toggle here. Make sure you add them 34 00:01:56,520 --> 00:02:00,240 with the Run... here. Alright, and if you 35 00:02:00,240 --> 00:02:04,530 want to remove a file, simply right click Delete. 36 00:02:05,220 --> 00:02:11,009 Are you sure? OK. So you can add one file per 37 00:02:11,070 --> 00:02:13,830 exercise. Okay, so the first exercise you are 38 00:02:13,830 --> 00:02:16,080 going to ask for the name and age of the user and 39 00:02:16,080 --> 00:02:19,260 print the info. This actually is what we have done 40 00:02:19,500 --> 00:02:22,320 to explain the functions here. So this is already 41 00:02:22,320 --> 00:02:24,750 done. But as an additional practice, you can just 42 00:02:24,750 --> 00:02:27,660 start with a blank page and rewrite that function, 43 00:02:27,720 --> 00:02:31,260 okay as the first practice. And then so ask the 44 00:02:31,260 --> 00:02:34,920 user for two integer numbers, add them and print 45 00:02:34,980 --> 00:02:37,530 them with the result. So you can create here a 46 00:02:37,530 --> 00:02:40,590 function to add two numbers and return the value. 47 00:02:40,710 --> 00:02:43,200 And then you can print the result. And for the 48 00:02:43,200 --> 00:02:46,710 third one, create a list of four float numbers, 49 00:02:46,710 --> 00:02:49,500 compute the average and print it, you can create a 50 00:02:49,500 --> 00:02:53,190 function here that is going to compute the average 51 00:02:53,220 --> 00:02:56,730 of any list of numbers Okay, so you're going to 52 00:02:56,730 --> 00:03:00,240 call this function and print the result. So those 53 00:03:00,240 --> 00:03:02,850 are the three first exercises and then the fourth 54 00:03:02,850 --> 00:03:05,790 one is a new exercise. You're going to create a 55 00:03:05,790 --> 00:03:09,450 function to convert from Celsius degrees to 56 00:03:09,450 --> 00:03:12,360 Fahrenheit degrees, okay. You have the formula 57 00:03:12,360 --> 00:03:14,940 here. So you have Celsius degrees you need to 58 00:03:14,940 --> 00:03:20,580 multiply Celsius by 1.8 and add 32 to get 59 00:03:20,610 --> 00:03:24,120 Fahrenheit degrees. Okay, so for each of those 60 00:03:24,120 --> 00:03:28,080 exercises, one of the challenge also will be how 61 00:03:28,080 --> 00:03:30,780 you can name the function okay. Naming the 62 00:03:30,780 --> 00:03:32,970 function is very important to give a meaningful 63 00:03:32,970 --> 00:03:35,340 name and then how you are going to organize the 64 00:03:35,340 --> 00:03:38,940 code to make it work. Alright, so now if you still 65 00:03:38,940 --> 00:03:41,730 have some trouble understanding some concepts, 66 00:03:41,760 --> 00:03:43,860 please go back to the previous lessons to watch 67 00:03:43,860 --> 00:03:47,310 them again. And I will see you in the next video 68 00:03:47,310 --> 00:03:50,102 for the solution of the exercises.