Hello, and welcome to Python For Everybody. My name is Charles Severance and I am your instructor. We named this Python For Everybody because we are dedicated to the notion that Increasingly as our lives are surrounded by technology. That we want you to become a maker of technology and not just a consumer of technology. You wanna change your perspective from this side of technology, where you’re looking at it, to the other side, where you’re back here. You’re like a creator of the technology and you can create things. And it takes a long time, and you may not want to be a professional programmer ever. You might just read a little bit of data.
But we believe that everybody should know basically, how to program, and how to get things done inside of a computer. Just as much to just be a responsible participant in modern tech, increasingly technically oriented society. Computers want to be helpful. They are programmed, they are designed, the hardware is designed. We’ll talk about hardware in the next segment. But it’s designed and wired, and when you apply electricity to it, it basically has one question. And that is, what do you want to do next? And if you think about your phone, and all the apps that you have on your phone, each app is like what to do next, what to do next.
So, as a programmer, your job is to serve the user. The user has something they want to do. Maybe they want to zing a bird towards a pig. Or maybe they need to analyze some data. Or maybe they want to do something like talk to their phone. And you have to be a real advanced computer scientist. And so, as a user, we just have so many wonderful programmers who’s put so much software that make these phones intelligent. The hardware itself is not all that intelligent. And our job as programmers is to act as intermediaries between the hardware and the user to build something wonderful and beautiful.
And so, you can kind of imagine that your job as a programmer is to intermediate between the hardware and the end user. And if you’re a professional programmer, and you’re trying to sell your software, well you’re trying to imagine what the world might want. You can imagine all these app stores, etc. And, these are places that you can build software and exchange that software with other folks and help people out. And like I said, we’re trying to flip you from one side of these device to the other side of this device, where you are the maker. And, you can think of these as a tool to manage your calendar or drive your car and read a map or whatever.
But when you look at it from the other side, when you look at it from being a programmer. You use things like compilers, and interpreters, and programming languages, and networks, etc. And we actually have tools that we’re going to learn to use. Python is a tool that the programmers on the backside of this computer use to make new things for the front side of the computer. Now, what’s your motivation to become a programmer? Well, the kinda gross motivation for professional programmers is to build something for everyone else to use. Like I work on this open source software called Sakai. Which millions of people use around the world teaching and learning.
It’s very rewarding for me, I feel really good about that. You might build a guest book for a website. But that’s generally is not the first thing you’re gonna do with your programming skills. You might get some data, you might be an accountant or you might be a lawyer or you might be a librarian. And somebody’s got some data, and you can’t get a report out of this data, something you’re really curious about. Somebody says, could you knock out a little piece of Python code to count up the number of times that this happens on Saturday, but then it also happens again on Monday. Tell us how many times that happens.
And so you write 40 lines of code and it comes up and tells us what that data is. And that’s really useful. The key difference between writing a program for someone else and writing a program kind of for yourself to consume or just a few other people is the rigor. You don’t have to be such a professional just to write code that you can use yourself. If it works and it gets you the data you want then job done. If you want to become a professional programmer, then you have to study how to be more precise and more engineering. But we’re not gonna worry about that in this beginning set of courses.
We just want you to learn the mechanics and the language of programming. And so we kinda wanna take you from being a user to being a programmer. And as a programmer, you start thinking of yourself as living inside the computer. So, you’re a consumer out here, you’re clicking on buttons and stuff. And so as a programmer you’re gonna write code, and that code is going to use data, and networks, and CPUs, and memory, and then do something for the user. So we’re trying to change your perspective, and sort of pull you into the computer. But what are you doing in that computer, what’s code, what’s software, what’s a program? Well, a program is like a sequence of stored instructions.
And the idea is that the computer itself at the lowest level in the hardware is just not that smart. But it has a lot of flexibility in that if we get the right instructions, it can do amazing thing. If we get it right instructions to listen to voice digitize voice, that make sense to the voice. Then, you can write a program that can hear, the computer doesn’t hear. The program hears. So the computer makes it so that it can run all the calculations that seems to make it hear. But a human being, or actually thousands of human beings, made it possible, so that you can talk to your phone.
And so you can think of, at the far end of this, when you’re building something really brilliant, like the ability for a computer to listen to you. You are taking you and all your creativity and all the research that you’ve done, and you’re building something really amazing and put it in the computer. But it is still a stored series of instructions that run step by step, and someone figured out every single little step that has to happen. And so, once we’ve figured this out, we write the instructions carefully and then we give it to somebody. Here is a program that does voice recognition. And if you’re interested in it, I say it’s wonderfully creative.
As a professional programmer, I have loved my life. I have loved the kinds of things that I do, that I build things for people and I make them happy. And then I sort of feed off of that. And then I build something else. But ultimately, it’s just a set of instructions. If you’re like, what’s in a set of instructions? Well, here we go. Here is a program for a human being. Now, I may be showing my age a little bit, but this is a YouTube video. Hopefully is not taken down by copyright or whatever, on this song called the Macarena. And so the Macarena is an algorithm, or a series of steps.
That hopefully you, five years ago, or many years ago, you’d go to the bar, and you’d watch all these people doing these things. Putting their hands up, and putting their stuff on, wiggle, wiggle, wiggle, and turn it around, right? And you’re sitting there, going, okay, what’s the sequence of instructions that they’re doing? As a matter of fact, there’s a looping thing. As long as the music plays you put your left hand out, you put your right hand out, you flip your left hand, flip your left hand, flip your right hand, I forgot all about it. But, here’ something I want you to do. I want you to look at this slide and I’m gonna be quiet for a minute.
I want you to look at this slide. Pause the video, if necessary. There are three bugs in this program. It looks right, but there are three bugs, so I’m gonna stop for a second.
So hopefully you paused if you had to. But, now I’m gonna come back and I will show you what the bugs are. And here are the bugs. Now if you didn’t find them, even if you look closely, you have learned something about human beings. And that is that, we human beings operate in an error filled world. There’s typographical errors, people say things incorrectly, and we as people just fix them as we’re perceiving them, as we understand them. But even as you read this, you might not have seen these mistakes, because your brain just fixed them. Because we just fix errors in our environment, it’s what we do. Computer’s aren’t like that, they are not like that.
Although, voice recognition, after a while, that software does learn how to filter out errors. But, that was really hard to write, okay. Computer do not understand how to filter out errors. But with enough instruction, you can kind of get them to filter out errors, okay. And that’s why search engines kind of work their, it’s sort of this soft intelligence, but it was really hard to build. But, when we start talking about writing programs, whether it’s writing programs to do search engines or writing programs to do voice recognition. Those programs have to be perfect. They make the tiniest typographical error, those programs simply do not work. And so here we go.
So here we say right ham to the back of the head. What, where was there ham in this? So you got this ham in your hand and you, what, hit in the back of your head. You may not notice this, but the computer is literally going to say, that’s syntax error, I quit. Right? And so, syntax error is the moment where the computer says to itself, I don’t know what to do. And the same thing is true here, I’m gonna hit somebody, what are you talking about? And so the computer is gonna be completely lost by this. You might look at this and you might just fix it and compensate for it.
So that’s sort of a little set of programming experience, programs for people. So that’s the, that’s the code that’s right. So, let’s talk a little bit about programs in Python. Like I said, it’s a set of instructions. So I’m gonna put up some text here, and I want you to count the number of each word in this text. And then tell me what the most common word is and how many times this word occurs. Here we go.
Count. Just count, concentrate. Concentrate, concentrate, concentrate. And part of the interesting thing here is not so much whether you can count those words or not. But how your mind is actually reacting to the problem that I just placed you in. You’re probably like, this is just not good. I’m so good, I can drive a car, I can play baseball, I can catch something, I can sing a song. And yet to be focused on counting these words seems really, really annoying. It turns out this is one of those things, text analysis, is one of those things that computers are really good at. And we humans are really bad at. So it’s really great to delegate this problem to a computer.
If you know the language of the computer and you can talk to the computer. And so I don’t expect you to look at this code. We’re gonna spend many weeks looking at all of the basics of this thing. But this is a program. This is a set of instructions. It’s got 2, like 6, about 11, 12 lines of code. And in it we have instructed the computer to read through a bunch of text, count the words, and tell us what the most common word is. And so if we run this program and we give it a file of words, it’ll say the most common word is ‘to’, and there’s 16.
That clown.txt that I just asked you to the the most common word, and there are 7 of those. And so, this is basically an outline of a program, I mean it is a program that solves this problem that we will learn about. Just so don’t try to learn this right away. Up next we’re gonna talk about the hardware architecture. And what goes on inside the computer that you’re going to make use of as you become a programmer.