Python for Absolute Beginners Transcripts
Chapter: Problem solving techniques for writing software
Lecture: Practice time

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now it's time for you to get some practice. Remember, without practice you do learn some stuff but not as much of course.
0:08 And boy do we have a cool example that you can start from scratch and really build out in this chapter.
0:13 We're going to go and do basically what I described. I'm going to give you a problem. Maybe somewhat like something you've seen, but not the same
0:20 and you'll be able to apply things like divide and conquer and go through it and build it out. I think you're going to have a lot of fun.
0:27 Here we are in the GitHub repository and let's go down its got the standard overview. The core concepts are me laying out
0:33 my problem solving techniques. Here they are. Divide and conquer. Have you seen a similar problem before? Visualize the data.
0:41 That could be at it could be in the debugger as we just discussed. It could be just calling print and passing the data, whatever works.
0:48 Visualize the data. Think through the data structures that might apply here. Is there a PyPI package?
0:54 This is an external package that solves this problem. And you might also check Awesome Python. More on that in a moment.
1:00 And remember, if you feel stuck working through this that's part of the journey and it's also the reason it's so cool
1:06 to have something nice working at the end because you had to slog through a little bit of it, right? So it's the payoff there as well.
1:13 And finally, just start. Get going. You can use your refactoring tools and refactoring and rewriting ideas to make it better once you learn more.
1:21 Now, what are you going to build? Well, there is a game called Connect Four. This is a game by Hasbro and it looks like this.
1:29 The idea is you basically drop items different colored chips into the top. And whoever gets four as they pile up here
1:37 either diagonally, horizontally, or vertically wins the game. Kind of like tic-tac-toe a little more complicated
1:43 but in terms of the way the code works, not very much. Here's some info on wikipedia and over here you can actually play it online.
1:49 So your goal is to start from scratch and build this, right? So think about what you saw in the videos. Have I seen a similar solution?
1:56 Choose the right data structure run through your choices there and break the problem into smaller parts.
2:03 Divide and conquer, just like we did in tic-tac-toe. This one will probably take you awhile. If you get it done in less than an hour
2:10 and you're new to programming, I'll be impressed. So be prepared to put a little effort into it but I think it's going to be a lot of fun
2:16 to have when you're done. So it's probably not going to be super fast to solve and you know, that's part of the journey.
2:22 So now, create a new project and just start. That's the recommendation. Alright, before you actually start, one more thing.
2:28 I told you one of the techniques it doesn't apply in this problem but in general, if you're trying to accomplish something
2:35 and you've used your divide and conquer bits to break it down and then you realize there are some steps that are like Download this webpage.
2:42 Understand all of the content, and find this thing. You could do a really lot of hard work there or you could check PyPI over here.
2:51 This is where all of the Python libraries are and you can see there's 215,000 different libraries. There might be one that solves that problem.
2:59 So we could actually check. Let's suppose we want to go to a website download it, and understand it
3:03 and ask questions about the data that's on the page. We could look for web crawling and that's one of the terms or web scraping is another.
3:11 Awesome, there's a bunch of stuff here. However, there are 10,000 plus different libraries. Whoa! Which one's good? You want to try 'em all out?
3:20 I don't know. You can also drop in over here and sometimes they'll have a category for what you're looking for. For example, web crawling.
3:28 And down here they list many once you finally get there many of the popular ones. They have MechanicalSoup. They have Scrapey some various other ones.
3:36 Visual scraping with Scrapy and whatnot. Beautiful Soup is also another option which kind of a derivative of this.
3:43 I'm not sure why that's not listed there. Probably should be. But these are some of the more popular ones in that category.
3:49 So when it comes down to step five is there a PyPI package? Maybe use things like Awesome Python to help narrow down the search
3:58 if you don't know where to go. Alright, get to it. Go build a Connect Four clone and have a lot of fun.

Talk Python's Mastodon Michael Kennedy's Mastodon