Python Jumpstart by Building 10 Apps Transcripts
Chapter: Course Conclusion
Lecture: Course and app review
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's review what you've learned in each one of these apps. When I first introduced the apps I told you what you are going to learn
0:07
but you had never seen it so you know, it probably didn't really resonate the way it will now.
0:12
So let's go through and just kind of review really quickly and if you had to reinforce one of these concepts,
0:16
just jump back to either the concept video from that app or the code, or play around with it some more.
0:22
So in app 1, this was our simplest app, it was the Hello World app,
0:26
remember, the goal was really to test your Python environment get your editor set up,
0:31
things like that, not really to prove that you can write print hello world, that's silly, right. So, we sort of introduced PyCharm here,
0:38
we talked about variables, strings, and accepting user input and this was really sort of getting our feet wet, getting started.
0:45
Next app was, what I kind of considered our first real app, that's Guess That Number Game, and remember,
0:51
the computer randomly select a number between 0 and 100 and then it would tell the user hey, you are too high, too low, as it took in the guesses.
0:57
So in order to do that, we had to understand boolean conditions, we had if, else, elif statement, while loops
1:04
and when we start talking about these concepts like if else statements and while loops we have to talk about the shape of a Python program
1:12
and here we learned about the white space and indentation and how the smart editors help with that,
1:17
we also talked about string formatting with the curly braces to sort of generate strings in a much nicer and more flexible way,
1:23
and we got the very basics of functions go in there as well. App 3, When Is My Birthday this one was all about dates, times and time spans,
1:31
now these can be tricky in Python so I made this special app just to help you become comfortable with those
1:37
and sort of reinforce what we learned in the first two apps. App number 4 was our Journal or a daily diary and this was pretty big,
1:45
we covered a lot of stuff, this was our first sort of major app I would say.
1:49
And, because it was a bigger app we actually broke our code into multiple files, we had our journal, module, and we had our main program.py
1:57
and we had those work together, we did a lot of file I/O and to facilitate that we did path management and in OS independent way using you know,
2:06
not surprising the OS.path; we used for in loops and iterators, obviously playing a key role in the for in loops, because we had these different files,
2:14
we might want to reuse the methods and features of one of those modules, and if we have been just calling main,
2:22
or just writing our code directly, like write in line there, we wouldn't be able to import those, so we talked about the dunder name convention,
2:29
to differentiate between when your program itself is being run and when your script is being reused.
2:36
Also we talked about documenting your own code with docstrings. App number 5, this was our weather forecast app and we went out to weather underground
2:44
and we grabbed the HTML and we did that using a technique called screen scraping
2:48
by making an http request, using the request package pulling that down, taking the HTML, send it off to the BeautifulSoup package
2:55
and then writing css selectors against that in memory to actually pull out the data we want.
3:01
In order to get Requests and BeautifulSoup, which are external packages,
3:05
we used pip and we could further isolate our particular environment in our application using virtual environments.
3:14
Along the way I also got to introduce you to a very Pythonic concept called slicing.
3:17
App 6, I hope this one made you laugh, this was the Lol Cat Factory, And this was all about consuming services and working with binary data,
3:26
so recall, we went out to our lol cat service, we downloaded a bunch of binary images, and we saved them to the file system
3:33
and then we used Python to subprocess capability to launch the finder or folder browser explorer depending on your os,
3:41
we'd launch that up to actually show the UI since we are not diving into things like PyQt and so on.
3:48
App number 7 was our Dungeon and Dragons Style Wizard Game, this was one of my favorites and this one is about
3:53
a very core concept in modern programming and Python classes, inheritance, things like that. So we talked about how you create classes,
4:02
and model your data structures with classes, and inheritance allows us to sort of separate that into layers,
4:07
so it's more reusable, more manageable Python has magic methods, sometimes are referred to as dunder methods, like __init__(), __str__(),
4:16
for overwriting behaviors of our classes, our objects for example we can write the __init__()
4:22
to take control over the creation and initialization of our objects, and speaking of initialization, we saw when we are doing inheritance
4:29
that you need to be careful about chaining these together in the correct order so the whole hierarchy get setup correctly.
4:36
Typically, this is where you define your fields and these __init__() methods and when we are using our objects you don't have static typing in Python,
4:45
instead we use something called duck typing to achieve polymorphism.
4:48
In application 8, we built a file searcher app and we got to feed a ton of data to it,
4:54
remember we had our 2.27GB of text what we were searching with this thing, so in order to make that much more performant and efficient
5:03
we used generator methods using the yield and yield return keywords,
5:08
and because we were trying to process a hierarchy, a tree of data, the file structure, we used recursion which models that scenario very well.
5:18
In app 9, we got hold of that comma separated value data on the Sacramento real estate market in 2008 I believe it was.
5:28
And we loaded that up, we did all sorts of interesting processing on it, we saw that at the heart of Python are dictionaries,
5:35
and dictionaries of course played a key role in our comma separated value processing as well;
5:40
we wanted to sort the data that we got back out of that file and we did that by passing a method
5:45
we saw that methods were first class objects in Python, and when you want to write really small concise ones, it's much better to use
5:53
a lambda method or lambda expression rather than creating a method somewhere else and just so that you can pass the name in where you are.
6:00
We talked about the csv file format and how Python has built in support for processing that, we also saw that we can run into a situation
6:07
where Python 2 and Python 3 behave differently, remember we had the statistics module that's in Python 3.3 and above
6:14
but not in Python 2 so we wrote special code to sort of do a polyfil or fill in that missing piece for Python 2
6:21
and the consumers further down in our app didn't have to worry about whether there was the statistics module
6:28
we introduced a less efficient but sufficient one for them to use. we also saw that many of those situations that are solved with loops and lists,
6:35
so looping over a bunch of data, doing some tests, things like that, can be solved much more concisely with list comprehensions.
6:44
And while solving problems with lists is great, in app 8 we saw the performance implications
6:49
that you can run into if you are processing a lot of data in a pipeline. So, in app 8 we used generator methods,
6:56
there is a similar concept in this comprehension style called generator expressions
7:01
so we use those generator expressions to create efficient data pipelines. The last app we built was app number 10, The Movie Search App.
7:10
This went out to the open movie database api and it pulled back data. And that was interesting, we were processing json and things like that,
7:17
but the key focus of this app was to build reliable code. When you have a network based code chances that the network is down are pretty good,
7:28
especially if you are running on a client machine like a laptop where it could be out of wi-fi range or whatever.
7:33
So we need to be able to handle those errors we introduced the try except block to do that,we also saw that you can use multiple except blocks
7:40
to handle errors by type, remember, put them both specific one first the most general one last,
7:45
we also talked about validating arguments by raising errors; we had some kind of argument pass doing init method for a class
7:53
the init method doesn't have a return value that you can pass back and say false or none or something like this,
7:59
but we still want to validate the arguments coming in and so we saw that we could raise an exception when invalid data was passed
8:06
and then the object would never even be created unless it started out in a valid state.