Python for Absolute Beginners Transcripts
Chapter: Problem solving techniques for writing software
Lecture: Some techniques for problem solving in programming

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Before we get into our new project that we're going to work on, let's talk about some techniques and ideas that'll help you
0:06 get started when you're trying to solve a problem and you're not sure what to do. The first thing to ask is have you seen similar problems.
0:14 Have you seen solutions to similar problems. You're not completely new to programming. You've already made it part way
0:20 through this course, for example. Have we worked with data in some way that is similar to this? Have you been looking around on the internet
0:27 and seen other ideas and solutions that are maybe out there, or other tutorials? Have you worked on something like this before?
0:34 This is really, really helpful because you can compare what that problem and solution is to what you need to do
0:40 and see how they're the same and different. And when they're the same they can give you some guidance on what to do.
0:45 Visualizing the data is really helpful, as well. It's one thing to say well, I have, I don't know this data and some file and it's kind of hard
0:53 to conceptualize or whatever. But if you can see it, and maybe this is loading into Excel, this is maybe this is seeing the data in a debugger
1:04 or something like that. If you can see the data, you could even just print it out and see what comes out. If you can see the data that can help you
1:10 think about how you need to interact with it. So this is an important role, an important step in here.
1:17 Divide and conquer: you've probably heard this one before for problem solving but it's really, really important. Imagine you're writing a commerce site
1:24 you might be working on the part of the problem where it's, like, let the user buy something. Okay, well that sounds really complicated
1:32 so what's involved with that? Well, you've got to charge their credit card you got to verify some stuff you got to get their shipping information
1:38 and then you got to send out an e-mail receipt. You've got to actually have the stuff sent to them.
1:43 Whew, that's a lot to think about all going on there. But break it into smaller pieces. One of the steps there is, send them an e-mail.
1:49 Okay, well, think about how to send an e-mail. And you can research that really clearly. One of the steps is getting their shipping address.
1:56 Well, how might you get their street, their city their state, and so on, from them? Well, that's not too intimidating likely.
2:03 So, breaking it down into these steps these high-level steps, and then trying to attack them one at a time, and maybe even breaking those
2:09 into further, smaller steps is super, super helpful. Run through the data structures. We saw using the right data structure
2:16 in our rock-paper-scissors game simplified the code dramatically. It let us think about an even more generalized
2:23 problem, actually simpler than our small simple case. Remember we switched out, like, the rules of the game
2:31 from if, else statements down into a simple dictionary. And in that chapter, we talked about the different
2:36 kinds of data structures that are very, very common: lists, sets, dictionaries and then, even some of the other ones.
2:43 But just thinking through when you're at a lower level of this divide and conquer stuff how do you store the data and interact
2:49 with it in the right data structure? That can make a huge difference. Another one, which we haven't touched on yet
2:56 because we're just focused on getting the basics of Python working, is the external package ecosystem in Python.
3:04 So the place that you go and get these packages is called PyPI, or the Python Packaging Index. And it's at pypi.org.
3:10 Over there, there's 215,000 libraries meant to solve certain problems. So, if you're trying to do something
3:19 like some complex step, like, let's say, send an e-mail there's a ton of libraries over there built for sending e-mail.
3:25 If you're doing something with physics instead of doing all the Python code to actually do some complex physics calculation
3:31 there's probably a library, just say do that calculation, and it just does it. So if you can solve the problem by having someone else solve it for you
3:40 and by that I mean using a library that already solves that problem that is a really good option. So be sure to check that out.
3:46 Sometimes it's daunting to see so many different libraries and know which one you want so check out awesomePython.com. They have sort of a ranking of
3:55 the popular ones categorized by the different types of areas you're working. Also, just realize this is part of the journey.
4:04 It may feel like, well I'm stuck because I'm a beginner, I'm stuck because I'm not good at programming, I'm stuck because, whatever.
4:11 No, everyone goes through this. Everyone who works on creating software has to go through these steps of the blank page
4:18 with a cursor just looking at them and some problem to solve. You get better, quicker at running through
4:23 these different techniques, but you got to realize that it's part of the journey and just take it for what it is, and enjoy it.
4:29 Some parts will be frustrating but then when you solve them it'll be really, really satisfying. So part of the journey. And finally, just start.
4:37 Sounds simple, a lot of people have problems with this. It's easy to sit around and think, and think, and think
4:42 and plan, and compare, and think about trade-offs and what not, when you're trying to solve these problems. Maybe I should do it this way
4:48 maybe I should do it that way. Oh, what about this? It can get really overwhelming and you can just get stuck in what's called analysis paralysis.
4:56 That's just trying to analyze the problem and never actually getting started. Here's the thing about software:
5:01 you write it one way, if you don't like it that way you change it. You have data one way, you don't like it
5:05 you convert it to another structure or format data structure, whatever. As you get started, as you make progress
5:12 you realize what the detailed steps are what mistakes you made, go back and change them. So just start, and once you've got an idea just run with it.
5:21 If it's not the best idea, back track a little and then you can change it. Nothing's set in stone. It's just words and characters on a screen, right?
5:28 So here are a handful of techniques to help you solve some of the problems that you might run into to create the software that you're trying
5:36 to create as a software developer.


Talk Python's Mastodon Michael Kennedy's Mastodon