What is python programming || Why python programming is used
We got a question, we just gotta get this out of the way.
"What is programming?" I mean really... that answer will come about... the real answer to that question
reveals itself the more you do programming. But let's talk about it kind of in general for a second, the thing we have to realize is okay... I wish I had like Google glasses on, I could just like POP
show you what I'm looking at, but that computer, there's a computer over there.
It's not very smart, it's incredibly powerful, it's kind of amazing that they exist, and that they can do all this stuff but it doesn't know how to do anything. At all. Nothing! It needs human beings
to write instructions for it to do certain things -- to crunch some numbers, to draw certain colors to the screen -- everything has to be written as instructions for the computer. And this is really what it means to program, to write those instructions, to write an algorithm. What is an algorithm? It's just a sequential list of instructions that solve a particular problem. An algorithm for example -- I can't believe I'm going to use this as an example but you know "you put your right hand in, you put your right hand out, you put your right hand in and you shake it all about".
You know "Hokey Pokey". It feels really ridiculous to do but that, that's a program. Not for a computer to follow perhaps but for a toddler. As you may be painfully aware these videos are not planned or
rehearsed! That might be a good idea to start doing but I went off on a tangent about the Hokey Pokey
I don't edit them either but this is a moment we're editing. So let's let's just sort of think of another example here, OK? So let's say that you need to... you've met somebody who has very poor dental hygiene(?) and they never brush their teeth, and you need to explain to them how to brush your teeth. Well, how would you do that? You might say "you know the toothbrush, put toothpaste on it and like brush it back and forth". Right? That might be some instructions. But what we have to realize with programming, and one of the things that makes programming
hard, is this fact that the computer doesn't have any intuition or ability to -- you know -- to communicate from human being to another human being with instructions. There's body
language, there's intuition, there's all sorts of ways that we communicate without kinda detail and specificity. Writing computer programs, you need that specificity and that's one of the things that's going to make it hard I guess, is understanding the syntax and the fact that if I say... um... "teeth your brush", you could probably figure out -- that sounds a little weird -- that I meant to say "brush your teeth". But a computer, you know, if you just left out one word, one letter, one semi-colon, one piece of punctuation, the whole thing's just not going to work at all and that's going to make things kinda challenging.
The other... the so... but let's return to this brushing your teeth. So let's let's actually be even a little bit more specific. We might say you know the first step is "locate toothbrush", right? The next step is "locate toothpaste". I don't know how absurd we need to get you know... pick... you know, you know, we could say like "move finger one away from thumb". You know, "Use the fingers to pick up the toothbrush", right? We could get so crazy specific. But you know, we need to say like "squeeze the toothpaste onto the toothbrush", right? There's just a sequence of steps here. And you know rather go through this myself you might take this as a little exercise to yourself -- you know, really try to do this, and then you know, find a very willing and kind friend to try to follow the instructions literally andsee like did they perform the program correctly?
Were there are bugs in your system, right? You know how how does that really work? But I want to mention a few other things about this. So let's say um...let's consider the following What if I said even before this step "If it 9 a.m. do this."? Right, so if it is 9 a.m. locate your toothbrush, locate your toothpaste, start these steps. So these are the things that we... that I'm just starting to point out, the fact that programming, it isn't just a matter of saying "do this, do that, do this". There are... there's logic, there's there's there's a sort of sophisticated logic that possible here, where we start having conditions "if this condition is met perform these steps". That's one of the things that you want to start thinking about right? "If it's the morning brush your teeth.
If it's noon... I don't know... stop making this video and go eat some lunch for God's sake." I'm feeling a little like... woozy but I think everything's gonna be fine, don't worry. Okay, so that's another thing. The other thing I might mention is that you might say "Okay, move... you might... we might have a step which is somewhere further along, "Put bristles on front teeth." The next step is "Move bristles horizontally and rapidly back and forth." Or something. I'm just making up these steps. "Move the bristles horizontally amd rapidly back and forth".
I don't know... is this really... am I really here talking about how to brush your teeth?
Oh my goodness. So you might do this, but
but but one thing we might say here also is "repeat
number six ten times." Sorry, I'm just showing you that
as you start to write out these steps, think about "Are there conditions? Are
there things that get repeated?" How would you really design this algorithm that has a beginning, a middle and an end that someone could follow and no detail would be lost?
This is really the beginning of writing a computer program. And if you think
about making the game "Pong" you're really going to be doing the same thing,
right? You're going to be saying "Draw a rectangle on the left side of the screen.
Draw a rectangle on the right side of the screen. Draw a
rectangle... a circle... in the middle. Move the circle towards the rectangle. If the
circle hits the rectangle, turn the circle around, right?" This set of steps -- "If the circle goes past the
rectangle, increase the score of the other player by one", right? Try to write out a list of instructions in English for the game "Pong". Now there's a couple things I want to mention about this
which is sort of exciting. One is we have just described this concept
known as -- I don't think I spelled it right -- "pseudo-code ". Pseudocode. This is something
that... uh... you will want to do in your future life, unless you've already turned this off
and you're bike riding or... I don't know, having a nice salad with a little... some nuts and cranberries is nice. But anyway... but pseudocode is something that you want to get used to doing, right? The syntax of programing can be
challenging, difficult and hard to do. If you can plan out your code in English -- or whatever your language is, whatever your language you think and
write and speak in -- then you can begin to design the steps of your program
in advance, which will help you when you go to sit down to actually write the actual code. But the other thing this brings up, which I think... I don't know if this has a real name anywhere other than in my
mind... but I'm going to say this thing called the 'philosophy of incremental development'.
Here's the real reason why programming is hard, why everything we're gonna do is going to be challenging and not going to be just... you're not going to do it instantly and you're going to struggle. You have a very very incredibly powerful thing in your head, which is your brain. And you can think about all sorts of sophisticated systems and ideas and design ideas and come up with the steps, the pseudocode, and understand how stuff works, right? Maybe you haven't played the game
"Pong" before, but if you have, you kind of know how it works. You could describe it to me, you could understand, you could probably without watching a single video anymore you could sort
of describe how to write the computer program for "Pong". But actually putting that down into code, all at once, is kinda impossible. This idea that you really need to get used to
is taking an idea like "Pong"... let's say the project -- and and you're gonna come up with
hopefully much more interesting and exciting creative ideas -- the project "Pong"...
Ah, I just realized I forgot to mention all the stuff in the introductory video, but
I'll figure out how to fit it in somewhere. The project "Pong", you wanna break that down in your head
into lots and lots of mini programs, right? Here's a mini program for you, one that draws
a rectangle on the screen. One that moves the rectangle up and down, just with the keys,
right? The up and down keys for example. Another program is one that just draws a circle in the middle of the screen, that moves the circle, that turns the circle around when it... you need lots and lots of little pieces. A program that... um... you can have a number appear on the screen that can go up and down,
maybe randomly. You need to divide "Pong" into lots and lots...
"Pong" wasn't the best example... but you want to divide "Pong" into lots and lots of mini programs, and make all those mini programs one at a time. Then you can start to piece them together.
You can't just sit down, "Do do do do do do do do do do do... I'm writing code for an hour or two. Finished. Done. Run. Ah, I have "Pong". You need to make lots and lots of mini steps, and
accomplish them one at a time. Always run your program, always make sure it's still working. Otherwise, if you write a ton of code, and then run it and it doesn't work,
where are you... how are you going to know what went wrong? Right? This idea of making
little incremental changes, taking a larger problem and breaking down into
smaller pieces, this is how you going to make stuff. But this is going to feel wrong to you
because you understand how it all works, and it's going to seem almost very kindergarten-sequel. Kindergarten is a wonderful place by the way, we should all just
live in perpetual kindergarten, we'd all be much happier. I don't mean that in a bad
way, but it's going to seem like I should be able to move faster than this. I should be able to do this more quickly, with more agility, but you have to think about it -- this is a very very flawed analogy here -- but you think about learning a new language, you know, a new foreign language, you're not going to pick it up immediately. It's going to be a long process, and the same is true for learning this new
language of writing code. Okay, so that's really "What is programming?" Kind of what is your first program, how we're thinking about and how we're going to approach all these problems as we begin to write actual examples, which we're getting to very soon.
Thanks for reading this article
👍👍👍
ReplyDelete