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