1 00:00:00,000 --> 00:00:04,600 [Intro Music] 2 00:00:04,650 --> 00:00:06,510 Alright guys, I hope that you were 3 00:00:06,510 --> 00:00:08,340 able to create this tiny Python 4 00:00:08,340 --> 00:00:10,290 application yourself. And now let 5 00:00:10,290 --> 00:00:12,000 me do that together with you. I 6 00:00:12,000 --> 00:00:13,380 have actually created this file 7 00:00:13,380 --> 00:00:14,910 before, but I have removed it 8 00:00:14,910 --> 00:00:17,160 just, and now let me recreate it 9 00:00:17,430 --> 00:00:19,440 from scratch. Let me go to Visual 10 00:00:19,440 --> 00:00:21,750 Studio Code, and here along with 11 00:00:21,750 --> 00:00:23,790 hello-world.py file in the 12 00:00:23,790 --> 00:00:25,950 same 'python' folder, I'll create a 13 00:00:25,980 --> 00:00:28,650 new file, 'calendar-app.py'. Let 14 00:00:28,650 --> 00:00:30,750 me close this 'hello-world' file. And 15 00:00:30,750 --> 00:00:32,670 here, let me click on 'python' folder, 16 00:00:32,700 --> 00:00:34,950 and create a new file called 17 00:00:34,950 --> 00:00:39,810 'calendar-app.py'. Great, let's 18 00:00:39,810 --> 00:00:41,850 first import 'calendar' module. It 19 00:00:41,850 --> 00:00:43,950 is built into the python module. 20 00:00:44,220 --> 00:00:48,510 Let me type 'import calendar'. And 21 00:00:48,510 --> 00:00:51,960 next let me print text to the 22 00:00:51,960 --> 00:00:53,730 terminal, and the text will be 23 00:00:53,730 --> 00:00:55,110 'Welcome to the calendar 24 00:00:55,110 --> 00:00:57,030 application!'. Let me copy it 25 00:00:57,030 --> 00:00:59,850 from here to save time, and let me 26 00:00:59,850 --> 00:01:02,220 use here single quotes like this. 27 00:01:02,460 --> 00:01:04,470 And afterwards, we need to get the 28 00:01:04,530 --> 00:01:07,650 input from the user, namely year 29 00:01:07,650 --> 00:01:10,230 number and month number. For that 30 00:01:10,230 --> 00:01:12,300 we could use the input command 31 00:01:12,360 --> 00:01:15,930 'input', and here will be, let me 32 00:01:15,930 --> 00:01:18,210 switch to terminal, and copy this 33 00:01:18,210 --> 00:01:22,020 text from here. So, 'Please enter any 34 00:01:22,020 --> 00:01:24,450 year:'. Afterwards, in order to reuse 35 00:01:24,540 --> 00:01:26,580 number that was entered by user, we 36 00:01:26,580 --> 00:01:28,800 need to assign it to some variable. 37 00:01:28,920 --> 00:01:31,800 And first let's parse it using 38 00:01:31,860 --> 00:01:34,590 'int' like so. And let's create a new 39 00:01:34,590 --> 00:01:37,380 variable, let's say 'year', and assign 40 00:01:37,380 --> 00:01:39,300 this result to that variable. In the 41 00:01:39,300 --> 00:01:42,030 same way, we need to get the month 42 00:01:42,030 --> 00:01:43,890 number and assign it also to the 43 00:01:43,890 --> 00:01:46,530 variable. Let's use 'month' variable, 44 00:01:46,560 --> 00:01:48,480 and here will be 'int', and here will 45 00:01:48,480 --> 00:01:50,940 be 'input', and let's paste here, 46 00:01:51,930 --> 00:01:53,940 input I will copy it from here, 47 00:01:54,480 --> 00:01:57,450 like so, paste here. And now we 48 00:01:57,450 --> 00:01:59,220 have two variables that will hold 49 00:01:59,220 --> 00:02:01,290 the year number and month number. 50 00:02:01,560 --> 00:02:03,660 And afterwards using this year and 51 00:02:03,660 --> 00:02:05,730 month, we need to call specific 52 00:02:05,730 --> 00:02:07,950 method of the calendar and print 53 00:02:07,950 --> 00:02:09,720 the result of that method to the 54 00:02:09,720 --> 00:02:12,030 terminal in order to see this month 55 00:02:12,060 --> 00:02:14,520 view. Let's do that. Let's use the 56 00:02:14,520 --> 00:02:17,160 print command, 'print', and here 57 00:02:17,160 --> 00:02:19,440 inside let's call a method called 58 00:02:19,440 --> 00:02:22,320 'month' of the 'calendar'. 'calendar. 59 00:02:22,440 --> 00:02:26,250 month', and here it gets two 60 00:02:26,250 --> 00:02:29,040 parameters 'year' and 'month'. 61 00:02:29,310 --> 00:02:31,140 Actually, we have reused here those 62 00:02:31,140 --> 00:02:33,600 two variables. That's actually it, and 63 00:02:33,600 --> 00:02:36,240 here after this line, we will 64 00:02:36,240 --> 00:02:38,400 get this output. And finally, let's 65 00:02:38,400 --> 00:02:40,410 print this line to the terminal. 66 00:02:40,530 --> 00:02:42,990 Let me copy it from here and use 67 00:02:43,020 --> 00:02:45,750 one more 'print', and here will be 68 00:02:45,750 --> 00:02:47,760 'Have a nice day!'. That's actually 69 00:02:47,760 --> 00:02:49,560 all for this tiny application. 70 00:02:49,590 --> 00:02:51,960 Let's save the file, go to 71 00:02:51,960 --> 00:02:55,170 terminal, and let me clear it, and 72 00:02:55,200 --> 00:02:57,720 run this application with the same 73 00:02:57,720 --> 00:02:59,430 command as I have used in the 74 00:02:59,430 --> 00:03:01,680 challenge task. Again, we run 75 00:03:01,680 --> 00:03:03,660 specific container in interactive 76 00:03:03,660 --> 00:03:06,060 mode with '-i' and '-t' 77 00:03:06,090 --> 00:03:09,240 options. Next comes volume mapping. 78 00:03:09,480 --> 00:03:12,840 We map local folder, 'python' 79 00:03:12,840 --> 00:03:15,000 folder with two files into 'app' 80 00:03:15,000 --> 00:03:17,070 folder inside of the container, and 81 00:03:17,070 --> 00:03:18,900 also we specify that we want to use 82 00:03:18,930 --> 00:03:21,090 that folder as working directory. 83 00:03:21,270 --> 00:03:23,220 If you do so you don't need to 84 00:03:23,400 --> 00:03:25,800 append here prefix 'app' before 85 00:03:25,800 --> 00:03:28,170 specifying the file name. And next 86 00:03:28,170 --> 00:03:31,200 we use python image and override 87 00:03:31,230 --> 00:03:33,510 default command using this part. 88 00:03:33,660 --> 00:03:35,700 And we simply run 'calendar- 89 00:03:35,700 --> 00:03:38,310 app.py' file using Python3 90 00:03:38,310 --> 00:03:40,470 interpreter. Let's press Enter. 91 00:03:41,940 --> 00:03:43,500 'Welcome to the Calendar application! 92 00:03:43,500 --> 00:03:45,540 Please enter any year:', let's say 93 00:03:45,570 --> 00:03:48,690 3000. 'Please enter any month number:', 94 00:03:48,720 --> 00:03:51,630 12, December; and I get this result 95 00:03:51,630 --> 00:03:53,520 in the terminal. That's how you're 96 00:03:53,520 --> 00:03:55,020 able to create this small 97 00:03:55,020 --> 00:03:57,060 application using Python. I hope 98 00:03:57,060 --> 00:03:58,710 that you enjoyed it. And actually 99 00:03:58,710 --> 00:04:00,390 that's all for this lecture. And 100 00:04:00,390 --> 00:04:02,370 that's all for Python part. If you 101 00:04:02,370 --> 00:04:03,960 want to create more complicated 102 00:04:03,960 --> 00:04:05,760 applications in Python, you could 103 00:04:05,760 --> 00:04:07,470 do that on your own. But the main 104 00:04:07,470 --> 00:04:10,140 goal of those several lectures was 105 00:04:10,140 --> 00:04:12,210 to show you how you're able to 106 00:04:12,240 --> 00:04:14,520 launch Python applications using 107 00:04:14,550 --> 00:04:16,709 python containers. I will see you 108 00:04:16,709 --> 00:04:19,019 next, and next we will try to create 109 00:04:19,050 --> 00:04:22,108 Node.js application. See you next. Bye-Bye. 110 00:04:22,108 --> 00:04:24,100 [no audio]