1 00:00:08,028 --> 00:00:10,240 - Welcome to Python Fundamentals live lessons part two. 2 00:00:10,240 --> 00:00:11,630 My name is Paul Deitel, 3 00:00:11,630 --> 00:00:15,330 and I'll be your instructor for these live lessons videos. 4 00:00:15,330 --> 00:00:18,350 Part two is based on chapters five through seven 5 00:00:18,350 --> 00:00:19,620 of our textbook, 6 00:00:19,620 --> 00:00:22,820 Intro to Python for Computer Science and Data Science. 7 00:00:22,820 --> 00:00:25,790 Learning to program with AI, Big Data and the Cloud. 8 00:00:25,790 --> 00:00:29,030 And chapters five through seven of Python for Programmers, 9 00:00:29,030 --> 00:00:30,623 which is our professional book. 10 00:00:32,180 --> 00:00:35,220 The prerequisite for part two of these live lessons videos 11 00:00:35,220 --> 00:00:38,050 is Python Fundamentals, part one, 12 00:00:38,050 --> 00:00:40,963 or equivalent Python programming experience. 13 00:00:42,470 --> 00:00:44,430 Many people find that as they work their way 14 00:00:44,430 --> 00:00:45,410 through the videos, 15 00:00:45,410 --> 00:00:48,550 it's helpful to have a copy of the book at hand. 16 00:00:48,550 --> 00:00:51,070 However, this is not required. 17 00:00:51,070 --> 00:00:53,370 There is additional information in the books 18 00:00:53,370 --> 00:00:55,368 that I don't cover as part of these videos. 19 00:00:55,368 --> 00:00:59,010 If you're interested in getting a copy of one of the books, 20 00:00:59,010 --> 00:01:00,900 you can find them in various print 21 00:01:00,900 --> 00:01:04,533 and electronic formats at the sites that are listed for you. 22 00:01:06,120 --> 00:01:07,480 If you're a college instructor, 23 00:01:07,480 --> 00:01:09,160 you'll probably want to take a look 24 00:01:09,160 --> 00:01:12,400 at Intro to Python for Computer Science and Data science, 25 00:01:12,400 --> 00:01:16,030 which is our college textbook version of the book. 26 00:01:16,030 --> 00:01:17,740 This one is in full color. 27 00:01:17,740 --> 00:01:22,610 It's 880 pages, 240 pages more than Python for Programmers. 28 00:01:22,610 --> 00:01:26,310 And in particular, it contains a ton of exercises. 29 00:01:26,310 --> 00:01:29,210 557 self check exercises, 30 00:01:29,210 --> 00:01:33,670 as well as 471 additional End-of-Chapter exercises 31 00:01:33,670 --> 00:01:35,170 and projects. 32 00:01:35,170 --> 00:01:36,970 Now many professionals find that they like 33 00:01:36,970 --> 00:01:38,750 to work with the textbook version, 34 00:01:38,750 --> 00:01:41,773 specifically because of the exercises. 35 00:01:42,887 --> 00:01:45,060 If you're interested in learning more 36 00:01:45,060 --> 00:01:48,480 about Intro to Python for Computer Science and Data Science, 37 00:01:48,480 --> 00:01:51,500 please take a look at the links that I've provided below. 38 00:01:51,500 --> 00:01:54,140 The first one is for an architectural diagram 39 00:01:54,140 --> 00:01:57,590 in which we show you the four part modular structure 40 00:01:57,590 --> 00:01:58,423 of this book, 41 00:01:58,423 --> 00:02:01,410 and that really applies both the college textbook 42 00:02:01,410 --> 00:02:05,250 and our professional book, Python for Programmers as well. 43 00:02:05,250 --> 00:02:08,960 The For programmers book has one fewer chapter, 44 00:02:08,960 --> 00:02:12,020 but the overall architecture of the two books is the same. 45 00:02:12,020 --> 00:02:13,800 And also in the For programmers book, 46 00:02:13,800 --> 00:02:17,210 we have less of the lower end pedagogical material, 47 00:02:17,210 --> 00:02:18,920 that's really geared to people 48 00:02:18,920 --> 00:02:21,320 who are novices in programming. 49 00:02:21,320 --> 00:02:23,640 The second link is for the full table of contents 50 00:02:23,640 --> 00:02:24,730 where you can see everything 51 00:02:24,730 --> 00:02:26,530 that we're going to cover throughout the book. 52 00:02:26,530 --> 00:02:28,660 And the third one is the books preface 53 00:02:28,660 --> 00:02:30,240 where you can learn more about 54 00:02:30,240 --> 00:02:33,230 our approach to teaching Python, Data Science, 55 00:02:33,230 --> 00:02:36,473 Artificial Intelligence, and various Big Data topics. 56 00:02:37,740 --> 00:02:38,900 I'd also like to recommend 57 00:02:38,900 --> 00:02:41,710 that you take a look at these two additional links. 58 00:02:41,710 --> 00:02:44,190 The first one is for the full book cover. 59 00:02:44,190 --> 00:02:47,860 And in particular, if you look at the back cover copy, 60 00:02:47,860 --> 00:02:50,400 you'll see a nice summary of everything 61 00:02:50,400 --> 00:02:53,220 that we're going to do throughout these live lessons videos. 62 00:02:53,220 --> 00:02:55,300 And I'd also recommend that you take a moment 63 00:02:55,300 --> 00:02:57,610 to read through the technical 64 00:02:57,610 --> 00:03:00,380 and academic reviewer testimonials, 65 00:03:00,380 --> 00:03:02,240 to really get a sense of all the things 66 00:03:02,240 --> 00:03:03,440 that they liked about 67 00:03:03,440 --> 00:03:07,000 how we presented Python, and the various Data Science, 68 00:03:07,000 --> 00:03:09,053 AI and big data topics. 69 00:03:10,900 --> 00:03:12,800 Back in lessons three and four 70 00:03:12,800 --> 00:03:15,850 of Python Fundamentals live lessons part one, 71 00:03:15,850 --> 00:03:19,440 we started to introduce a couple of the key data structures 72 00:03:19,440 --> 00:03:23,010 in Python, specifically lists and tuples. 73 00:03:23,010 --> 00:03:26,080 And here in lesson five of part two, 74 00:03:26,080 --> 00:03:29,530 we're going to take a look at those sequence data structures 75 00:03:29,530 --> 00:03:31,350 in much more detail. 76 00:03:31,350 --> 00:03:33,550 We'll talk about the various ways of creating 77 00:03:33,550 --> 00:03:36,750 and manipulating both lists and tuples. 78 00:03:36,750 --> 00:03:37,860 With respect to list, 79 00:03:37,860 --> 00:03:39,500 we're going to show you some sorting 80 00:03:39,500 --> 00:03:42,460 and searching capabilities that are built in. 81 00:03:42,460 --> 00:03:45,660 We're also going to go in-depth into a variety 82 00:03:45,660 --> 00:03:48,700 of functional style programming capabilities, 83 00:03:48,700 --> 00:03:52,050 both built into the language syntactically 84 00:03:52,050 --> 00:03:54,380 via what are known as comprehensions, 85 00:03:54,380 --> 00:03:58,100 and also via library functions called Filter, 86 00:03:58,100 --> 00:04:00,620 Map and Reduce respectively. 87 00:04:00,620 --> 00:04:01,453 For the first time, 88 00:04:01,453 --> 00:04:02,286 we're going to introduce 89 00:04:02,286 --> 00:04:05,060 a two dimensional list data structure. 90 00:04:05,060 --> 00:04:07,390 And we're only going to show one example of that. 91 00:04:07,390 --> 00:04:08,470 Because in reality 92 00:04:08,470 --> 00:04:11,730 when you get into multi-dimensional data in Python, 93 00:04:11,730 --> 00:04:14,020 it's almost always going to be implemented 94 00:04:14,020 --> 00:04:17,930 in the context of the NumPy open source library, 95 00:04:17,930 --> 00:04:22,430 which is the topic of lesson seven in part two here. 96 00:04:22,430 --> 00:04:26,090 We'll also revisit simulation a little bit in this lesson. 97 00:04:26,090 --> 00:04:28,470 And in particular, we're going to show you 98 00:04:28,470 --> 00:04:32,450 how to visualize the results of a simulation, 99 00:04:32,450 --> 00:04:36,140 in this case using the libraries called Matplotlib 100 00:04:36,140 --> 00:04:37,290 and Seabourn. 101 00:04:37,290 --> 00:04:40,690 Seaborne is actually built on top of Matplotlib 102 00:04:40,690 --> 00:04:43,483 and simplifies many of its capabilities. 103 00:04:45,020 --> 00:04:47,590 In lesson six, we'll continue our discussion 104 00:04:47,590 --> 00:04:49,870 of Python's built in data structures 105 00:04:49,870 --> 00:04:52,100 with dictionaries and sets. 106 00:04:52,100 --> 00:04:54,520 And just like we do for lists and tuples, 107 00:04:54,520 --> 00:04:57,350 we'll talk about the different ways of creating objects 108 00:04:57,350 --> 00:04:59,700 of these types and manipulating them. 109 00:04:59,700 --> 00:05:03,210 And that will include some functional style programming 110 00:05:03,210 --> 00:05:06,570 in the context of this thing called comprehensions, 111 00:05:06,570 --> 00:05:09,550 that we will first introduce in lesson five. 112 00:05:09,550 --> 00:05:12,800 As part of lesson six in the intro to data science section, 113 00:05:12,800 --> 00:05:14,360 we'll be talking once again 114 00:05:14,360 --> 00:05:16,410 about visualizations implemented 115 00:05:16,410 --> 00:05:18,840 with Matplotlib and Seabourn. 116 00:05:18,840 --> 00:05:22,890 But in this case, we're going to do a dynamic animated, 117 00:05:22,890 --> 00:05:25,007 die rolling simulation. 118 00:05:25,007 --> 00:05:27,850 And one of the cool things about this particular example 119 00:05:27,850 --> 00:05:29,710 is that it gives you a way 120 00:05:29,710 --> 00:05:33,833 to really visualize the law of large numbers in action. 121 00:05:36,070 --> 00:05:38,540 To finish off part two of these live lessons videos, 122 00:05:38,540 --> 00:05:40,580 we'll take a look at lesson seven 123 00:05:40,580 --> 00:05:43,670 on array oriented programming with NumPy. 124 00:05:43,670 --> 00:05:46,420 Now NumPy is one of the most popular 125 00:05:46,420 --> 00:05:48,670 Python open source libraries. 126 00:05:48,670 --> 00:05:51,340 It's used extensively by other libraries. 127 00:05:51,340 --> 00:05:55,730 Something like 450 of them are built on top of NumPy. 128 00:05:55,730 --> 00:05:57,070 So a lot of the techniques 129 00:05:57,070 --> 00:05:59,313 that I'm going to show you in this lesson, 130 00:05:59,313 --> 00:06:02,940 will also apply to other libraries as well. 131 00:06:02,940 --> 00:06:03,773 So for instance, 132 00:06:03,773 --> 00:06:05,920 when we get to the intro to data science section 133 00:06:05,920 --> 00:06:07,120 at the end of this lesson, 134 00:06:07,120 --> 00:06:09,920 we will introduce the Pandas library, 135 00:06:09,920 --> 00:06:12,910 which also is built on top of NumPy. 136 00:06:12,910 --> 00:06:14,973 So a lot of what you see earlier in this lesson, 137 00:06:14,973 --> 00:06:18,320 will also apply to Pandas as well. 138 00:06:18,320 --> 00:06:19,230 Throughout this lesson 139 00:06:19,230 --> 00:06:21,220 we'll do some of the same types of things 140 00:06:21,220 --> 00:06:24,270 that we did with Python's built in data structures. 141 00:06:24,270 --> 00:06:27,640 We'll show you various ways of creating NumPy arrays. 142 00:06:27,640 --> 00:06:30,230 We'll manipulate them lots of different ways. 143 00:06:30,230 --> 00:06:32,210 And one of the things that you're going to see 144 00:06:32,210 --> 00:06:36,340 with NumPy arrays is that you do a tremendous amount 145 00:06:36,340 --> 00:06:38,780 of functional style programming. 146 00:06:38,780 --> 00:06:40,330 So there's a concept 147 00:06:40,330 --> 00:06:43,460 that's built into NumPy called broadcasting 148 00:06:43,460 --> 00:06:45,050 that allows you for instance, 149 00:06:45,050 --> 00:06:48,170 to take a NumPy array which could be millions 150 00:06:48,170 --> 00:06:53,050 or billions of elements and multiply every element by two. 151 00:06:53,050 --> 00:06:55,640 And the expression that you use to write that, 152 00:06:55,640 --> 00:06:58,640 looks just like a regular arithmetic expression, 153 00:06:58,640 --> 00:07:01,400 but somehow NumPy behind the scenes, 154 00:07:01,400 --> 00:07:03,640 can parallelize that operation 155 00:07:03,640 --> 00:07:06,170 and do it extremely efficiently. 156 00:07:06,170 --> 00:07:10,100 So one of the key things with NumPy is its performance. 157 00:07:10,100 --> 00:07:12,950 And we will actually do performance comparisons 158 00:07:12,950 --> 00:07:17,870 to show you that NumPy can be up to 100 times faster 159 00:07:17,870 --> 00:07:20,150 than doing similar operations 160 00:07:20,150 --> 00:07:24,180 on Python's built in list data structure. 161 00:07:24,180 --> 00:07:25,700 We're going to show you by the way, 162 00:07:25,700 --> 00:07:27,870 both one dimensional NumPy arrays 163 00:07:27,870 --> 00:07:30,010 and multi dimensional NumPy arrays. 164 00:07:30,010 --> 00:07:33,220 And as we move into the intro to data science section 165 00:07:33,220 --> 00:07:34,210 of this lesson, 166 00:07:34,210 --> 00:07:36,530 we'll be focusing on the Pandas library, 167 00:07:36,530 --> 00:07:38,590 which is built on top of NumPy. 168 00:07:38,590 --> 00:07:41,373 So a lot of what I showed you earlier in the lesson, 169 00:07:41,373 --> 00:07:44,610 will also apply in the context of Pandas. 170 00:07:44,610 --> 00:07:45,930 What Pandas does though, 171 00:07:45,930 --> 00:07:49,080 is it gives you even more capabilities. 172 00:07:49,080 --> 00:07:50,120 And in particular, 173 00:07:50,120 --> 00:07:53,070 you'll frequently use Pandas in subsequent lessons 174 00:07:53,070 --> 00:07:54,260 to do things like, 175 00:07:54,260 --> 00:07:57,250 load data into your system for analysis, 176 00:07:57,250 --> 00:07:59,490 prepare the data for analysis, 177 00:07:59,490 --> 00:08:01,000 get to know the data 178 00:08:01,000 --> 00:08:04,550 by doing things like calculating descriptive statistics, 179 00:08:04,550 --> 00:08:07,660 or doing basic graphing of the data as well. 180 00:08:07,660 --> 00:08:09,070 So here we'll just start 181 00:08:09,070 --> 00:08:12,060 to introduce the functionality of the Pandas library 182 00:08:12,060 --> 00:08:15,140 and its two key data structures series 183 00:08:15,140 --> 00:08:16,610 which are one dimensional, 184 00:08:16,610 --> 00:08:18,990 and data frames, which are two dimensional. 185 00:08:18,990 --> 00:08:21,300 And then we'll continue that discussion 186 00:08:21,300 --> 00:08:24,950 in subsequent intro to data science sections in part three, 187 00:08:24,950 --> 00:08:29,333 and we'll use Pandas a lot in the later lessons as well.