Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
43 views

Backup of Python

Uploaded by

dudu Chou
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Backup of Python

Uploaded by

dudu Chou
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Video: Welcome to Class - Dr.

Chuck
0:04
Hello, my name is Charles Severance. I'm a Clinical Professor at the University of Michigan
School of Information, and I'm your instructor for this course. This course is a little different than
every programming course that I've ever taught, or I've ever taken. This course is dedicated to
the notion that every single person on the planet needs to be able to write programs and can
write programs. You do not have to have a bunch of math. I do not expect math. I do not expect
that you've taken any other programming classes. I don't expect you know anything about
computers. I think no matter what your background is, you can program. That's why it's called
Programming for Everybody. I have a couple of goals. Certainly, I want to teach you how to
program. But actually what I really want to do is teach you how to take a programming class
because it turns out that most of the other programming classes in the world are kind of difficult.
They sort of assume way too much and the teachers sort of don't even realize how much they're
expecting from students. So when you're done with this class, you can go and take another
beginning class. And that way you have this as an on-ramp to all of your programming activity.
And so I'm really excited that you're here. Another thing that I want to do is I want to teach you
how to be a mentor. I want to teach you how to be a teacher of programming. So I want you to
take all my ideas, and I want to you to help the next person. And the reason is that learning how
to program is a little sort of foggy, uncomfortable, you get stuck on things, and those things aren't
hard, I assure you. But when you're stuck on them, they feel really hard. And the best way to get
unstuck is get some help from somebody. And if they're sitting right next to you, and they can go,
"Oh look. You've just got to like add two spaces and it's fine." And you're like, "Oh, that saved me
a lot of time." So I want you to be willing to help somebody else. Another thing that's important to
me is that I want to create more teachers. Whether they're at universities, or community colleges,
or high schools, or even middle schools, or in professional situations. I have given you all of the
materials for this course at a website. They're all licensed under Creative Commons, the slides,
the autograders. I want you to in a sense adopt this textbook, and then use my teaching kit so
that you can become a teacher of this material, because I don't think that I'm naturally the only
teacher of this. And in particular, if you don't speak English as your first language, you might
want to teach this class in your native language. And so that's another reason that I give you
these materials with a free and open copyright that you can take them, you can translate them
into your language. The book has been translated into several languages. And that's really
exciting. Those books that have been translated are usually free and available. You can get print
copies that are very inexpensive and all the ecopies are free. And so this notion that I create this
kit, that you can then change the kit. You don't have to just take my class. You can change it and
you can make it work for you locally. And really, the overall goal of this is more than just like
teaching you one programming class. I think that the entire technology marketplace, and to some
degree all of business in general is becoming increasingly technical. And too many people,
young, old, regardless of education, are shut out of this sort of club where you need to know
something about technology. And so that's why we're Programming for Everybody. Regardless of
geography, regardless of ability to pay, regardless of if you have any disabilities, I want
Programming for Everybody to be everybody. I want when to just expand forever the number of
people who are capable of programming. It's an open self-sustaining ecosystem, and have you
be part of that self-sustaining ecosystem. So again, welcome to the class. I look forward to what
you do and I look forward to seeing you throughout the class.
Video: Welcome to Python - Guido van Rossum
[MUSIC] I'm Guido van Rossum. I created the Python language. I have worked on Python for 25
years and I have worked with a large group of others of course in the Python community. I'm very
excited to see you all in this class. And I'm very proud that you're using my language to learn.
Python is just the first step you're setting on the path to programming. There are many exciting
things to learn in programming. Many that you can learn using Python, many that you can learn
using other things. And you won't be alone. There will be millions of people who have gone
before you or, or who are learning Python at the same time as you. And you, you can help each
other, and you can learn together. [MUSIC]

1.1 - Why Program


Hello, and welcome to Python for Everybody. My name's 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, not just a consumer of technology. We want to change your perspective from this
side of technology where you are looking at it, to the other side where you're back here. You are
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 like 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 a modern, increasingly
technically oriented society.
Play video starting at 1 minute 4 seconds and follow transcript1:04
Computers want to be helpful.
Play video starting at 1 minute 7 seconds and follow transcript1:07
They are programmed, they are designed, the hardware's 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 have
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. And you could 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.
Play video starting at 2 minutes 31 seconds and follow transcript2:31
And like I said, we are trying to flip you from one side of this device to the other side of this
device, where you are the maker. And you can think of this 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 are going to learn
to use. Python is a tool that the programmers on the back side of this computer use to make new
things for the front side of the computer.
Play video starting at 3 minutes 6 seconds and follow transcript3:06
Now, what's your motivation to become a programmer? Well, the kind of gross motivation for
professional programmers is to build something for everyone else to use. Like I worked 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 not the first thing that you're going to 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,
it's something you're really curious about. Somebody says can 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 out 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 kind of have to study how to be
more precise and more engineering. But we're not going to 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 kind of want to take you, like I said, 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 going to write
code and that code is going to use data, 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.
Play video starting at 5 minutes 3 seconds and follow transcript5:03
Well, 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
give it the right instructions, it can do amazing things. If we give it right instructions to listen to
voice, digitize the voice, and make sense of the voice, then you can write a program that can
"hear". The computer doesn't hear, the program hears. 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 could 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,
Play video starting at 5 minutes 51 seconds and follow transcript5:51
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 runs step by step, and someone figured out every single little step that has to
happen. And so once we 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.
Play video starting at 6 minutes 36 seconds and follow transcript6:36
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, it's 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
would got to the bar and you'd watched all these people doing these things. Putting their hands
up and putting their stuff around, and wiggle, wiggle, wiggle, and turning around, right? And
you're sitting there, and you're like okay, what's the sequence of instructions that you'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's something I want you to do. I want you to look at this slide. Now, I'm
going to be quiet for a minute. I want you to look at this slide, pause the video if necessary. This,
there are three bugs in this program.
Play video starting at 7 minutes 32 seconds and follow transcript7:32
It looks right, but there are three bugs. So I'm going to stop for a second.
Play video starting at 7 minutes 45 seconds and follow transcript7:45
So hopefully you paused, if you had to. But now I'm going to come back and I will show you what
the bugs are. And here are the three bugs. Now if you didn't find them, even if you looked
closely, you have learned something about human beings and that is that we human beings
operate in an error-filled world. There are typographical errors, people say things incorrectly. And
we as people just fix them as we're perceiving them, as we understand them.
Play video starting at 8 minutes 14 seconds and follow transcript8:14
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.
Play video starting at 8 minutes 26 seconds and follow transcript8:26
Computers 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? Computers 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, they're, it's sort of a 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 text contextual or typographical error.
those programs simply do not work. And so, here we go.
Play video starting at 9 minutes 6 seconds and follow transcript9:06
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 went, hit in the back of your head.
Play video starting at 9 minutes 15 seconds and follow transcript9:15
You may not notice this, but the computer is literally going to say, 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 gotta hit somebody, what are you talking about? And so the
computer is going to 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, programs for people. So that's the
code that's right.
Play video starting at 9 minutes 47 seconds and follow transcript9:47
So, let's talk a little bit about programs in Python. Like I said, it's a set of instructions. So I'm want
to put up some text here and I want you to count the number of each word in this text and then
tell me what's the most common word is and how many times this word occurs. Here we go.
Play video starting at 10 minutes 11 seconds and follow transcript10:11
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, ooh, 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 going to spend many weeks looking at all the basics of this thing,
but this is a program. This is a set of instructions, it's got two, six, 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, "the" is
the most common word, and there are seven of those. And so, this is a, this is basically an
outline of a program, that, I mean, it is a program that gets solves this problem that we will learn
about. So, don't try to learn this right away. Up next, we're going to 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. Hello, and welcome to Python for Everybody. 

1.2-Hardware Overview
Welcome back. 
Now, we're going to talk a little bit about hardware architecture. 
You might ask yourself sort of why all these terms, and words, 
and central processing unit, what I want from this section is I just want to 
define a few terms, so that I can use them in the rest of the course. 
That's really it. 
I want you to have some sense of the basic block diagram of things. 
Now in the old days, I'm going to show you three generations of hardware. 
I'm going to show you really old hardware from the 60s and 70s. 
I'm going to show you sort of medium old hardware from the 90s and early 2000s. 
And then, I'm going to show you sort of super brand new 
hardware that sort of this is a Raspberry Pi and 
it's the kind of highly integrated hardware that goes into things like the cellphone. 
So I'll kind of be going back and 
forth between three complete generations of hardware.
Play video starting at 1 minute 7 seconds and follow transcript1:07
But the picture and the concepts that I want you to understand are these terms. 
Central processing unit, main memory, secondary memory unit, 
and input/output devices. 
So we'll start with input/output devices. 
They are the way that this computer accesses the outside world. 
So things like the mouse, the keyboard, right, I got a keyboard here.
Play video starting at 1 minute 31 seconds and follow transcript1:31
Keyboard. 
Screen. 
All these things. 
I don't want to mess up the keyboard there. 
And so these are the input/output devices. 
There is a little, that's okay just mess up a little bit, no problem at all. 
Output devices, screens, and 
that's sort of how the humans in the outside world interact. 
Software, the main inside the computer, we have the central processing unit, and 
the main memory, and then the secondary memory. 
And so it's probably easier for me to take the, neither the oldest nor 
the newest, to give you a sense of what is going on here. 
And so, if you had a desktop and maybe you still have one of these junky old desktops 
at home, they are the ones that are big and they make noise when they start up, 
they have in them a number of different parts and 
the closest thing that a computer has to intelligence is this. 
Central processing unit, CPU is what we call them. 
And if you look at the back side of this CPU it is actually a circuit. 
It's a highly sophisticated circuit with millions of transistors on it, and 
you've probably heard that, millions of transistors. It runs 
maybe three billion instructions per second. 
What does that mean? 
Well that means that an instruction is a set of electrical pulses, 
maybe 32 little wires or 64 little wires. 
And at three billion times a second, this is programmed to ask what's next. 
And it pulls what's next in these little electric wires. 
Well, where does it get the answer to what's next? 
It gets the answer to what's next out of the memory. And so your program, 
when you write a program, let me draw this, when you write a program, 
you create a file on the secondary memory, like a Python file, and then at some point 
that is loaded into the main memory, translated, and then your program is here. 
And then when the CPU says what next, your program feeds its first instruction. 
And then when that's done, the CPU says what's next? 
It feeds the second instruction, third instruction, fourth instruction. 
It's called the fetch-execute cycle. 
And these two parts, the CPU and the main memory, are what participate. 
And the main memory is where you kind of live. 
Somewhere in there, a little tiny version of yourself is in there 
answering the questions that this is asking. 
Now you might say how smart is this, it's not really very smart at all. It's 
a really fast hand calculator with lots of storage is the best way to think about it. 
And going back to the 60s and the 70s, 
this is a piece of hardware from a computer that was the size 
of a room with probably 20 refrigerators, all with modules that make this up. 
And in here, well you probably can't see it, you've got resistors, 
transistors, and capacitors, and then wires. 
The wires are all printed on this printed circuit board, otherwise known as PCB. 
And so, the closest thing this has to intelligence are these transistors. 
And at their simplest, 
what they can do is they can sort of make really simple yes/no decisions. 
And then they also can be used, if you hook them together the right way, 
to store a little bit of information. 
And so, when we say there are millions of transistors 
packed into this little tiny square right here. 
It's kind of pretty. 
I mean, if you look at it, it's sort of, it looks almost like a jewel, it's so pretty. 
And each one of those is a real tiny photo-imprinted transistor and 
so there are millions of this. 
And so the difference between 1960 and 
today is this part gets smaller and smaller and smaller to the point where 
literally thousands of these things are all squeezed in to that little square. 
And coming back to sort of the mid-grade one, so this one here is the motherboard. 
This part here is the motherboard because it's the mother of all boards and 
it connects everything together. 
All these components plug in and that's how they are connected together and 
there's a whole bunch of wires that go back and forth on this and so 
this is how your program in a sense is transported from the memory to the CPU. 
And so, this motherboard connects them. 
Another thing that's connected to the motherboard is secondary storage. 
Now, the reason we have to have secondary memory or secondary storage 
is this is designed to be really fast, the main memory is super fast. 
And what happens is when the computer turns off, 
your program is erased from here. 
And so I originally said that you write your program, and 
you put a file in here, a .py file, and 
this is the same place that your Word files are, and your PowerPoints are. 
And then, the .py file is kind of loaded and translated into the main memory. 
And then when the computer shuts off, all this data goes away. 
Secondary memory is permanent. 
This does not get shut off. 
And so, in the old days, this old-day stuff, 
we used to store our programs and our files on our hard drive. 
And you may even have a computer at home 
where there's a actual physical spinning platter of magnetic media and 
a little head that goes in and out to read and write the data. 
And so it actually records magnetically when you put a file in, 
it records it and then when the power's off the magnetic recording stays here. 
And so these things, physical disk drives, are kind of going, 
becoming extinct, because all the data is in little USB sticks like this, and 
that's a perfectly good version of secondary memory. 
But at least for us, we can look at these beautiful antique 
mechanical gadgets that we used to store data magnetically when the power goes off. 
Now, this one here is pretty broken. 
[LAUGH] And it's pretty in bad shape, so 
it's probably not really storing much of anything. 
So in a summary of this picture, 
the thing I really want you to get out of this picture is a series of definitions. 
The Central Processing Unit is very simple, 
it's the closest thing computers have to brains, but 
it wants to answer the question what to do next, but we have to feed, through memory. 
the answers, which is your programs. And then we have input devices, 
output devices, the main memory, and 
then the larger permanent storage in the secondary memory. 
So, where you live inside of a computer is basically in the main memory. 
When you write a program, you type it in the computer, you outside the computer 
are typing on your keyboard, and you're typing Python commands into a file. 
Like if x less than 3, print, right? 
And then, that gets loaded into the main memory, and 
so you, this is a creative version of yourself. 
It's your instructions that are going to be run and 
that program ends up in the main memory, and then it's run. 
So, this is sort of where you live inside the computer. 
Think of it that way. 
You're living in main memory when your program is actually executing. 
Now, it turns out that the instructions that this 
central processor uses are a series of zeroes and ones. 
And when I said like 32 zeroes and ones, or 64 zeroes and 
ones, simultaneously are fed into this for each of the instructions. 
We use a language called machine language. 
And I would love some day to teach you machine language, but 
we don't have time right now, and you, that is more moving towards being 
a computer scientist when you start learning machine language, but 
basically we don't have to worry about that too much, we write Python. 
And we write in Python and 
then something effectively translates it into machine language and 
then machine language is the thing that runs and runs and runs and runs and so. 
Someday you might take a look for that, but that's more of a computer science 
thing and the software that does this translation, 
which is either called a compiler or an interpreter, 
we can talk more about that when you become more of a computer scientist. 
But for now, we're going to worry about how to write this code and 
the rest of this sort is going to fall by the wayside as we go forward. 
So, I got a couple of videos here.
Play video starting at 9 minutes 36 seconds and follow transcript9:36
This one video, hopefully the YouTube URL is still good, 
if not we'll try to find another way to get you linked to a good copy of it. 
But it, basically, these, as I said, there are millions of transistors 
in one of these things, and there's a lot of electricity going through these things. 
And when your computer heats up on your lap, 
it's this little part here that's working really hard. 
Its doing things three billion times a second. 
So someone has made a video, not a very good video, but 
it's from a long time ago, where you take the cooling part off and 
you watch what happens to these CPUs when they're doing all this work three billion 
times a second using all this electricity and they're not properly cooled. 
Another cool video that we have is a video of hard drives and 
how they actually spin in reality. 
This one is totally messed up because I've been beating on it for years and 
playing with it, using it in all my classes for years, so it's in really bad shape. 
But this video shows you how that works and how it actually spins in reality. 
And you'll hear noises that if you have or had a desktop computer,
Play video starting at 10 minutes 36 seconds and follow transcript10:36
you'll kind of recognize the noise, and then you'll have an idea of what's going 
on inside that computer as that secondary storage is moving around. 
And like I said, secondary storage is becoming less and less relevant as we move 
to solid-state storage, like the kind of storage that's in a USB stick.
Play video starting at 10 minutes 55 seconds and follow transcript10:55
So up next, we're going to talk about how we write that Python. 
I talked a little about the hardware now, and 
now we're going to get started writing some Python.

1.3 - Python as a Language


[SOUND] So now we're going to talk about Python as a programming language. 
You probably noticed that I'm wearing a sorting hat. 
The reason I'm wearing a sorting hat is that where I work at the University 
of Michigan School of Information, we are in a building called the North Quad. 
And you can look it up on Google and find a picture of it if you like. 
And I think it's designed to be like Hogwarts. 
It's got a little center, it's got this outside bit, 
it's got a really cool cafeteria that looks like owls might fly through it. 
And so we moved to this a few years back when I started teaching Python. 
And I was teaching my very, very first class in this building, 
which we've sort of lovingly called Quadwarts, because it's North Quad and 
we thought it was kind of like Hogwarts. 
And so, I'm joking, and I wore my robes to class, and 
I said welcome to Quadwarts, and you have to wear your 
robes every time to class, and I was being funny. 
And I said okay, it's our first class, we're teaching Python, and 
let's do a sorting ceremony. 
I didn't have the sorting hat back then, so I have a sorting hat now.
Play video starting at 1 minute 25 seconds and follow transcript1:25
And so, that's cool. 
And I'm like, I think I'm going to be in Gryffindor. 
And they told me, the students said that I couldn't be in Gryffindor.
Play video starting at 1 minute 34 seconds and follow transcript1:34
And I'm like, why can't I be in Gryffindor? 
Everybody wants to be in Gryffindor. 
And they told me that I was teaching Python.
Play video starting at 1 minute 42 seconds and follow transcript1:42
Python is like a programming language that's based on a snake. 
And even worse, my name's Charles Severance, and I'm like Severus Snape. 
And so they basically told me that I had to be in Slytherin. 
And so since then, I've bought many Slytherin items, I got Slytherin wands, 
when I graduate, you'll see my Slytherin wand. 
I got a sorting hat, so you'll see me drinking tea throughout the class,
Play video starting at 2 minutes 11 seconds and follow transcript2:11
from my Slytherin cup and so I guess I'm just doomed to be in Slytherin. 
I don't know if that means I'm a good guy or a bad guy, or a good guy that seems 
like a bad guy or bad guy that turns out to be a, right, it's a lot of book. 
So, the whole thing about being in Slytherin is that you can talk to snakes 
because you can talk this weird language that others don't understand.
Play video starting at 2 minutes 33 seconds and follow transcript2:33
Python's like that.
Play video starting at 2 minutes 35 seconds and follow transcript2:35
Python's a language that most don't understand. 
You, of course, will begin to understand it.
Play video starting at 2 minutes 43 seconds and follow transcript2:43
It's a weird language, it's strange, it's not easily understood by others. 
We call ourselves Pythonistas. 
And Guido van Rossum, over 20 years ago, invented this Python language 
that we have grown to know and love, and has become so important.
Play video starting at 3 minutes 0 seconds and follow transcript3:00
And while I'm going through all this like snake stuff, 
it turns out that that is not at all why Python was named Python. 
Python was not named for 
a snake even though we use the snake motif all the time. 
It turns out that what Python was named for was Monty Python's Flying Circus. 
And the reason was is that Guido was trying to capture an air of play. 
Most programming languages in the 80s when Python started were very, 
very serious, and very complex and you had to be really serious to figure them out, 
a lot of math geniuses. 
And Guido thought, I could probably write a programming language that 
wouldn't be that hard, would be fun actually, 
would be enjoyable to use, but let's not make it bad. 
Let's not make it weak, let's make it both powerful and enjoyable. 
And so that's why Python turns out to be such a perfect language 
to use as your first programming language, is that it's designed 
to be your first programming language but it's also powerful. 
So many times you build a first programming language that's weak. 
And not capable of doing a lot of stuff. 
But Python has this wonderful, easy to learn and powerful and useful. 
And so there we are. 
Welcome to being a Pythonista. 
Now. As you learn Python, remember, 
you're talking to a snake and this is a language that you don't already know. 
You are going to make lots of mistakes.
Play video starting at 4 minutes 28 seconds and follow transcript4:28
And the computer is going to seem to judge your mistakes harshly. 
You will learn the word "syntax error" a lot.
Play video starting at 4 minutes 37 seconds and follow transcript4:37
And, if you're like me, I think back to the first time that I was programming. 
I was typing stuff on cards, and you'd bring your card deck up and 
you'd hand it to the computer. 
And you'd read it through the computer. 
And then the computer would come back and say syntax error. 
And sometimes it took several hours to get back the results of your program. 
You're going to get to do it in seconds, but in the old days when I was young, 
it took hours sometimes. 
And then all you get back is a syntax error and 
when I first started programming, I grew to kind of hate the creature that lived 
inside the computer because I thought that the creature didn't like me. 
I thought the creature was value judging my programs. 
I mean, I would write this thing and I think it's perfect and I would hand it in. 
And the computer would say, syntax error. 
And I'm like, huh? 
What's up, syntax error. 
And then I would like, okay, I'll make my program better and here you go. 
And it would say syntax error again. 
And the thing that you're going to have to learn is that,
Play video starting at 5 minutes 38 seconds and follow transcript5:38
syntax error doesn't mean that Python thinks you're bad. 
It is not a judgement of your ability as a programmer, 
it is not a judgement of your potential to be a programmer. 
Syntax error means Python is lost.
Play video starting at 5 minutes 51 seconds and follow transcript5:51
You are learning Python's language because Python can't learn your language. 
You're smarter than Python. 
We can teach you. 
You can learn, but Python can't. 
And so when it says syntax error, even though you feel like it's a rejection, 
syntax error simply means that Python is lost. 
It just doesn't have really friendly words when it says it's lost, 
it just goes syntax error, which literally is exactly what's happening. 
Your syntax is not something that Python understands. 
So just understand as you go through the next couple of weeks that you will be 
frustrated.
Play video starting at 6 minutes 31 seconds and follow transcript6:31
It's not because you're a bad person, 
it's not because you're never going to figure it out. 
You will figure it out and you will get it. 
And you have to sort of trust us as we go through the first few weeks and 
learn the basics. 
And then as we connect the basics together,
Play video starting at 6 minutes 45 seconds and follow transcript6:45
then this thing will make a lot more sense. 
I remember when I was first learning to program, I would be like, lost, lost, 
lost, lost, lost, oh wow, I love this. 
And I expect that many of you will go through that exact same feeling so 
you have to trust us.
Play video starting at 7 minutes 1 second and follow transcript7:01
So up next, we're going to actually talk about the Python programming language.
Fun: The Textbook Authors Meet @PyCon2015
Camera and you're fine. Is it working? >> It's working. >> Are you selfie-ing? >> Yeah, this is
my selfie cam. My Gimble selfie cam. >> It works great. >> Yeah. So this way I can tape my
meeting of Allen Downey. >> Sweet. >> That's gonna be sweet. >> Moments. >> The
moment that I meet Allen. >> Palpable. >> It is. >> Very cool indeed, I'd say. [LAUGH] >>
Folks. That's Allen Downey, who started the whole Think Java, Think Python revolution. Back
in 1999, and I'm going to meet him now the first time. >> You can ask him that question that
I should have asked him a long time ago.
Play video starting at 1 minute 0 seconds and follow transcript1:00
>> [SOUND] So what are your thoughts, Jeff, before we meet the great Allen Downey? >>
But you've met Alan before? >> I have. >> This is my first time. >> But it's always exciting. >>
Exactly.
Play video starting at 1 minute 23 seconds and follow transcript1:23
>> I'm Charles Severance. >> Charles, it's great to see you. >> We're co-authors. >> Yes? >>
We've never met in person. We talked on the phone. This is the famous Jeff Elkner, of
course. >> Made famous by this guy. >> Well everybody got made famous. >> [LAUGH] >>
So the first question I was asking Jeff and he doesn't even know the answer to is why did
you choose GFDL back in 1999? That was before Creative Commons, before OCW, before
everything. What possessed you? >> You know, actually the first version of the book, I put it
under the GNU Free >> GFDL. >> Not not- >> GFDL. The GPL. >> Oh, you did the GPL. >>
Because I didn't even know about the GFTL. >> And then somebody got ahold of you, from
MIT. >> And they said wait a minute, this is documentation, this is not code. You should use
this other license, and so I switched. And then when Creative Commons came along, some
of those licenses has been useful. Actually part of the reason that working with O'Reilly has
worked out very well. I do things usually under a non-commercial Creative Commons
license, and then that's kind of a compromise. >> Yeah. >> So it's not ideal. >> But those are
the details, so why >> Though the non-commmercial's I think a beautiful thing. Actually
Creative Commons is thinking about getting rid of it. [INAUDIBLE] Yeah. >> And I'm sad
about that, because I think it is a fine middle ground. E-copies can delivered free and no one
feels bad about that. Print copies you make money off of. So it's pretty cool. >> I agree I
think there's a nice use case for it. >> So have you ever tried to count the number of
derivative books of Think Python? >> No. >> Do you think it's 100? 200? 300? >> I don't
think. >> How to Think Like a Computer Scientist Java version. >> If you go all the way back.
>> There are a number of English language books that are modified versions. >> Including
mine. >> There are translations into >> I count those as separate ones.
Play video starting at 3 minutes 14 seconds and follow transcript3:14
>> Yep. >> But like Runestone, like Brad Miller's stuff, >> Active more, I guess. >> Do you
have an interactive version? >> No no I just have the Python for Informatics print and e-
version. >> Yeah, that's >> I did that many years ago, and then I fought with Cambridge
Press. Remember that? >> Yes. >> Remember those calls? Yeah. So, but that's, but like why
did you give it away? I mean, it wasn't so cool in 1999 just to give books away. It was not
normal. >> True. No. But that's the question that I wanted. >> Can we pause? I do want to, I
want to finish signing books >> So we have to talk later. >> Okay, we'll get back to this. >>
[LAUGH]
Face to Face Office Hours - Bengaluru, India
Hello, and welcome to by far the largest office hours that we've ever had. We are in India
and Bengaluru. And it is the IT capital of India and it has the greatest weather of India. So
I've had a wonderful time, and we met a bunch of students, and we don't have time for you
to meet each one, so we'll just walk around and you can see just how many people are here.
So, here we go. So we will start like on a really big shot. So we see that we have a giant
room full of people. And now let's walk around and everybody can sort of wave and say hi?
Hello. Hi. Here we go. Make sure we see everybody, hi. Here we go. Things are working
pretty good. Not so bad. We could do better. Hello world. Hello. Hello, oh hashtag! Very well
done. Hashtag. So we have our blind contingent here at the front, of the blind programmers.
Hello. So coming down this way. Hello. Hi. Cheers to Coursera. Cheers for Coursera. Hello.
Hi. Yeah, here we go.
Play video starting at 1 minute 42 seconds and follow transcript1:42
Hi. That's right, there we go. Okay, so there we go. An amazing turnout, an amazing week,
an amazing day and then off to Mumbai we go. Oh, I should point to myself. So, we've had a
wonderful time here in Bengaluru and looking forward to seeing students in Mumbai later
this week. Cheers.

Demonstration: Using the Python Playground

So welcome to this week. Last week, we talked about the theory of programming, and
computer science, and the Macarena, and all that kind of stuff, and that's cool. But now
we're going to start writing programming, writing programs using Python. And one of the
things we're trying to encourage you to do is install Python and run it, because sooner or
later you are going to have to do that, right? You're going to have to install it and run it.
We've got a bunch of videos. But in Courses One and Courses Two, you don't actually have
to do that. Now, we know that some people are using iPads, or Chromebooks, or something
else, and you can't install Python. And maybe you're at a school that can't install Python, so
it's great that you can write Python programs using software we've provided in the browser.
And we have this Python Playground, and so as you go through the course, you'll find
assignments that you'll have to do. But what this is is this is an ungraded assignment, Python
Code Playground. And so it's launched externally, using a technology called Learning Tools
Interoperability, so it's going to pop this open in a new tab. So you see that it's in a new tab,
right? And it's the Python Code Playground. Now, this is kind of like the autograder except it
has no expectations, and you can write any code that you want, okay? And so let me hit the
Reset Code button, and you can always go back to the default code, and this is the code
that's there for you. And if I want to run it, I can just say, go ahead and run this code, right?
And so the code runs, and the output's over here. So it actually ran the Python, and the
code came out over here. Now, this is a file, this is like Chapter Seven, it's even from Course
Two, so the default code here is probably not what you want to play with. You can play with
something like print('play!'), and run that. And so it runs the code, and then your output
comes here. Now, there are three files, which is later, Chapter Seven and later, that you can
use. These are the sample files that we use throughout a lot of the assignments in the book,
and away you go. And so you can do whatever you want here. It's not being graded, there's
no grade being sent back to Coursera, and so away you go. And if you're writing Python on
your laptop or your computer, you're way better to just learn how to do Python there and
then paste the code in the autograders later. But if you have no access whatsoever, that's
why we give you the Python Playground. If you want to do this in Python 2, because the
course is taught in Python 3, there's a little button down here that says switch to Python 2.
And so you can run Python 2 code in here as well if you know Python 2. In the first ten
weeks of the class, you can actually switch back and forth between submitting your
assignments in Python 3 and Python 2, but in this case. Now, the other thing that's cool
about this is that you aren't going to see this button, you're not going to see any of those
buttons. This View Student Code allows our teaching staff to take a look at your code. And
so we don't allow you to paste code into the forums, so what you can do is you can ask for
help in the forums. And the teaching staff can go in and view the student code, type in your
name or email, and then find the code that you last put in. So you can put something in here
and get some help on it. The teaching assistant can see your entire code, they can run your
code, they can do all kinds of things. And so it's a great way to communicate with the
teaching assistant. You sort of leave your code in the Playground, you ask the teaching
assistant, and then they go take a look at your code and give you some answers. When
you're all done, you simply press Done, and we're back to Week 2. But like I said, I really
would personally prefer that you build the skills on running Python on your laptop as quick
as possible. But if that's not practical for you, then that's why we have the Python
Playground here in Courses One and Two.

You might also like