Subtitles section Play video Print subtitles Hello everybody and welcome to chapter one of Python for Everybody. I'm Charles Severance i'm your instructor and i welcome you to this class. The basic goal of this class is to teach everybody how to program regardless of your background. You don't have to be a math whiz. You don't have to be a computer expert. No matter how old you are or what your background is we want to teach you how to program. So welcome to this course. Welcome to chapter one. So the first thing to understand is that the purpose to learn to program is because computers want to do things for us they are built and created and designed and their hardware is set up so that they basically asked us what do you want to do next if you grab your phone your phone sort of does nothing until you tell it what to do with weights for you and is just waiting for you and all the hardware computer technology around you is generally waiting for you and we can use this for useful things we could play video games we could have it help navigate for our car someday we might even have self-driving cars and its really in a sense in my mind silly if you spend your whole life not really understanding this technology and and I think it's important that we learn to tell these computers what to do rather than just let them increasingly control our lives and so as we'll see computers aren't very smart on their own we humans are the ones that in view them with knowledge and what we need to learn to speak their language it is much easier for us to learn to speak their language than it is for them to learn to speak our language although with these cellphones we're starting to see little bits where they can begin to understand but you would be amazed at the 40 or 50 years that it takes has taken us to understand a hundred to build programs to begin to understand so I'm bringing you into something where you are going to learn the ways of programming in the let ways of the computer because it's easier to teach you how to program is to teach this how to work in your world even though ultimately the goal is to get this to to do work for you so part of what i'm trying to do is move you from a user perspective where you just look at the computer as something that someone else has constructed and you are the user of to the point where you construct new things now the first kinds of things that you're going to construct are actually things to solve your own problems and it's a very popular now to work on data and python is an excellent programming language for datum data mining and data analysis and that's a lot of what we're going to do in this course although really it's a gateway to all kinds of things like you know artificial intelligence or gaming navigation or mobile applications or entertainment all kinds of things but first we have to learn to program we have to move from using the computer as a tool to using the tools within the computer that allow us to change how the computer sees the world so there's a couple of reasons that you might want to be a programmer some of you are looking to improve your career to be paid to work on program and I've been a paid program for most of my life and I like it it's a good job you don't have to stand in the mud you don't have to lift things you have to use your brain and i'll just say that it is been nice for my career to not be exposed to the elements but to be able to work often wherever I want but that's actually our secondary goal our first goal is to get you to write programs that solve problems that you have to solve maybe you have a job as an accountant or a lawyer or something else and maybe you run across some data maybe there's some system that logs your time and it's not quite giving the report that you want to give and so you say could I just grabbed the log data myself and and write a program to do some analysis to say what's the average this versus that or the average of some other thing right and so that's the basic idea that you'll you'll initially use computers to serve your own ends that makes it a lot easier to write programs because you don't have to worry about you know a million users using your software you if it works for you then we're happy and so it takes a little more training to write software for other people are for thousands and thousands of other people and so part of what i want to do is I want to change your perspective you know you look at this from the outside and you see it from the outside and you click on things i want to turn this around and I want you to be the person inside this looking out at the world and as a programmer we are making things inside these computers for the world and so we want to pull you into being part of this we want you inside this are thinking inside this and what you learn is that if you're inside this computer and you are taking your instructions to build programs to be used by the human almost dropped that the human outside the computer you have things that you need to take advantage of there's things like the central processing unit the memory of this system the network connection of this system that the disk drive or permanent storage on this system and as a programmer you are kind of mediating between all those internal resources that this has that are not very smart but highly powerful and mediating with what that user wants right and so we take the end user and we programmers we serve the end-user but the computer serves us so together between us and all the computers resources we can serve the needs of the end user and we do this by writing code or programming ok and what is that well programming is a sequence of instructions where we are giving instructions the resources inside the computer in a way to accomplish the goals of the end user and remember sometimes we are our own end-user it's not just it's not just you know the you're not always doing a start-up you're not always writing a mobile gaming system sometimes you're writing something for yourself but that's okay so sometimes you're writing something to solve a problem you're like crafting your you're doing something you could do by hand or manually and you're you're making some clever little 2500 line program and you're putting that in other times like when I work on the open-source learning management system sakai it is my creativity I'm I've got an idea and I want to share it with a million users and so I write my code to for an external audience and so code is that sequence of instructions that the computer itself doesn't know how to handle roster out but i can write code that will handle roster out by looking at the data that's inside this computer inside this application and so if you think about programs we have programs for computers and programs for humans and a number of years ago now i'm started sooner or later this will be me showing my age this is an example of the macarena and the macarena is a song that effectively is a sequence of instructions you put your left hand out you put your right hand out you put on the shoulder you wiggle wiggle wiggle and you spin around and you do things and this this is a program for people and so I want you to take a quick look at this and see if you can find anything wrong with this particular program to look really closely so i'll show you it's got some typographical errors in it and we as humans are really good at reading or hearing typographical errors and correcting them automatically and instantly and but computers are not computers are extremely literal if it saw this ham instead of hand it would think what's a ham and why am I going to hit someone in the back of the head with a ham and why would I take my left hand and hit somebody that's you know these are all bad things but the computer is going to take us very literally and so we have to be really precise and and the computer just doesn't know the difference between what we mean and what we say so we have to be very precise and this is one of the great frustrations that people have when they first start using computers and so we have to get this right we have to get these little bits of text exactly the way they are computers will blow up with syntax errors and there seemed to to make quite a fuss when you make the tiniest of errors but you'll get used to that I mean that's because not because you're bad or you're less than awesome it just means the computers can't compensate when you make small mistakes and so you've got to get used to the fact that the computer is sort of intellectually not as strong as you and so it gets confused really easy even though when it gets confused it says seemingly mean things to you so you'll get used to that ok so the first thing i want to do is I want to throw up some text and I want you to while this text is up i want you to count the number of each word in this text and tell me what the most common word is in this text ok so here we go ok so I I kind of made that hard on you on purpose by moving around and distracting you and confusing you but even if it's it's not moving at all it's a little bit you know tricky to do you probably stare at a couple of times your brain is going back and forth and back and forth and so let's text analysis is one of the great things that computers are very very good at and some of the things that you know if they can translate text and that's because they looked at a lot of information so looking at text is actually something computers are really good at and so if we take a look at the kind of programs that we're going to write to do this kind of thing this is something that humans are not naturally good at but computers are super-good at now i'm not going to have you look at this code i'm not going to this code you will understand in a few weeks but basically this is a set of instructions to open a file read that file read all the words in the file create a histogram of all the words in the file and then search through that histogram to find the most common word and tell us what the most common word is in the file and in this clown file the word that is the most common it happened seven times and here's another large file called words that text and the word to is the most common thing and our goal is to get to the point where you can write this on your own so you can say you know what I got a problem to solve that is what's the most common word in this file I know how to start and then I know how to finish I know how to do this stuff in the middle and we have to learn this kind of weird language but when we do we can count millions of words as easily as account 20 words so that's the fun of all of this is to teach you this language so that you can solve that problem so that you don't have to solve it because you could solve it but it's not something that's not your naturally good at and it's hard work so next we're going to talk a little bit about the hardware architecture that you can you're going to be experiencing as you write programs
A2 US computer program user file solve write PY4E - Introduction (Chapter 1 Part 1) 87 7 Amy.Lin posted on 2017/09/12 More Share Save Report Video vocabulary