Python for Beginners, Part 5: Variables

image

Clever Programmer Hacker Noon profile picture

Clever Programmer

Clever Programmer is a community with over 100,000+ students who are learning to code by building real world projects.

We will discover what are variables in this video. How is data stored into variables and then how you can retrieve it later for easier access. We will look at all this through a visualization using the Turtle library from Python.

In case you missed it, here are the previous parts of the series:

Transcript

00:00 Hey guys, what’s up?

00:00 This is Qasi from cleverprogrammer.com.

00:02 Now in the last video, we talked about

00:05 how can you make a script that creates a square in one go?

00:12 Right, so I gave you an example of a script

00:16 that does not make a square in one go.

00:18 So I’m gonna start off in this video

00:21 talking about how to do that,

00:23 so I’m gonna solve that problem.

00:25 If you haven’t done it, go still try to do that problem,

00:28 but I’m gonna go over the solution and then after that,

00:31we’re gonna talk about what the heck are variables?

00:33 So let’s keep going.

00:34 So here if I run this code, right,

00:38 notice what actually happens, we get this thing,

00:41 but we don’t want it to go to the right and down.

00:44 We want it to keep going ’til it makes a square.

00:46 So I’m simply going to copy this code

00:49 and paste it again, except for this line.

00:55 I wanna turn 90 degrees, and then I wanna turn 90 degrees.

01:00 And go straight one more time.

01:02 So let’s run this bad boy, and check it out.

01:05 Let’s see what happens, okay.

01:09 And boom, we have gotten a square.

01:12 So if this was your code and you copied this,

01:15 and you went over to cleverprogrammer.com

01:18 or you went to YouTube, my YouTube channel

01:24 and pasted it below, that would be exactly

01:27 what you would need to do, okay.

01:30 So simple, go to Python for beginners

01:33 and simply go Turtle In One Go,

01:37 and you can paste the code right here, okay?

01:40 Back to what we were talking about.

01:46 Whoops, the video actually started.

01:49 So let’s talk a little bit about variables.

01:52 Variables are very simple.

01:55 It just allows you to store information somewhere.

01:58 Instead of having to say, oh yeah, my friend

02:02 with the white skin, or he has this length hair

02:07 and his nails are this long, and he’s this tall.

02:10 Instead of saying all of that,

02:12 we store all that information in his name.

02:15 So we just say John or Bob or whoever, right?

02:19 That’s exactly how variables are.

02:22 Instead of saying all these things at once

02:24 or having to remember them, you just store it in a variable

02:27 and then you just, you know, recall that variable,

02:30 and that’s it, so something really simple.

02:33 I could say Bob, right, is five years old.

02:40 He is 68 inches tall and wears brown suits.

02:49 Now if I said Bob, you could see Bob

02:53 or if I say x is equal to some big number,

02:57 good luck trying to remember that number,

02:59 but it’s pretty easy to remember x, right?

03:02 So you can say x, and you can say x plus 10,

03:05 or you can say x minus x, and you should get back zero.

03:10 Anyways, that’s…

03:12 Variables are very simple.

03:14 On the left hand side, you put what you want to store

03:17 information into and on the right hand side,

03:19 you put what you want to store in there.

03:22 Okay, that’s it about variables.

03:25 I’ll see you guys in the next video

03:26 where we talk about strings.

Tags

%post_title%

Cryptovixens Source

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest

Responses

Your email address will not be published.

Get 20% Discount

Sign up to receive updates, promotions, and sneak peaks of upcoming products. Plus 20% off your next order.

Promotion nulla vitae elit libero a pharetra augue

Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed