Python Tutorial 4 – Data Types and Ints

Let’s start with data types. So a variable, such as our age variable or our person variables, can be of many types. So far we’ve dealt with numbers and with text, which is known as ‘strings.’

The remaining three main data types are lists, tuples, and dictionaries.

Now we’ll get to these three types in a later on in a different tutorial, but for now we’ll just be learning about numbers.

We’ve already dealt with the basics of numbers such as:

age = 10

students = 20

You know the basics of how to add these numbers to variables. That’s basically the core concept of using numbers. Now what we want to learn is to add variables or subtract variables

The way we do that is with something called operators. You probably already know what these are: addition, subtraction, multiplication and division. Four simple operators.

Let’s make two variables:

age1 = 19

age2 = 52

So let’s quiz here. Make a third variable, age3, which is the sum of age1 and age2. How would you do that?

It’s actually quite simple. Do it this way…

age3 = age1 + age2

This is how we use operators. So now if you print out age3 you’ll be given the sum…71. That simple!

That was addition. Now let’s try subtraction, division, and multiplication.

age1 – age2

That subtracts and gives us -33.


Divided, which gives us…0.36538461538461536!


Multiplication; the sum is 988.

Now the last operator I want to talk about is, at least for arithmetic operators, is modulus.

All it does is give you the remainder of a division. So we had divided age1 by age2 and got 0.365…and so on.

age1 % age2

That’s how you use the mod to get the remainder.



Written for my own study of Python as I journey to learn it. I’m following the instructions from this YouTube video, and this section of the tutorial begins at 12:33

Python Tutorial for Beginners


Python Tutorial 3 – Multiple Assignments


So let’s say you have to create a variable for each person in a class room. Each will have different names and stuff, so creating, say, 10 variables would become a tedious task.

So for example, you would be writing them out…

person1 = “Abby”

person2 = “James”

And so on until you’ve reached person 10. And at this point you would be groaning about how much you hate Python as you collapse to the floor.

And this is why we’ll be talking about Multiple Declaration. All that does is allow you to assign multiple values to multiple variables into one line.

This is the way it works, try something like this…

person1,person2,person3 = “Abby”,”James”,”Lebron”

So if you do this and you type person1 into Python, you’ll be returned “Abby”. Type person2 and you’ll get “James”. And so on.

This quickens the tediousness of having to write out each individual variable and their value on separate lines.


So let’s see this from another case. Say you have a string called “Apples” and you have ten variables. You want all of those variables to have the value of “Apples” assigned to it. So something like this…

var1 = “Apples”

var2 = “Apples”

var3 = “Apples”

So how can we set all three variables to “Apples” without having to do them all like the above example?

Well there’s the concept of “Multiple Assignments.”

With this we can say…

var1 = var2 = var3 = “Apples”

This will set all three of those variables to have “Apples” as their value without having to do them all separately. Type var1 and you get “Apples”, type var3 and you get “Apples”!


So now we’ve learned how to quickly give many variables different assignments with “Multiple Declaration” and how to quickly set multiple variables to the same value with “Multiple Assignments!”

Written for my own study of Python as I journey to learn it. I’m following the instructions from this YouTube video, and this section of the tutorial begins at 8:49

Python Tutorial for Beginners

Python Tutorial 2 – Variables

This lecture is all about variables.

So first, what is a variable?

a variable is a reserved memory space. This memory space can hold any value and is assigned to a term.

So for example we’ll make a variable called age. So simply type out age on your shell. Now add an = equals sign after it. This tells Python we’re going to give this variable a value.

From here we set the value of the variable. You can set it to specific text using ” “ quotations  marks and spelling what you want in between, or you assign it a number simply by typing in your number.

age = “Hi there!”

age = 17

So we’ve created a variable with the name age and assigned its value to the number 17. So now whenever we call up the variable on Python, it will give us the variable we’ve assigned to it. So now if we enter age into Python, it returns to me the number 17, or whatever you’ve set its value to.

You can always change the value of a variable, as they are not permanent. So if we were to enter age again, and make it equal to “Hi there!” than it will now return to us “Hi there!” when we call upon the age variable, instead of 17.

So you can see that variables are very simple to set up. First you enter the identifier (variable name), like how we’ve used the name age. It can be anything: Bob, John, Pizza, Bacon…whatever you want it to be! After that you enter an = equals sign to tell Python that we’re assigning a value to our variable, then give it its value, just as we did 17 or “Hi there!”

But if you try to set print as the identifier, that won’t work because print is a function in Python.


Written for my own study of Python as I journey to learn it. I’m following the instructions from this YouTube video, and this section of the tutorial begins at 5:46

Python Tutorial for Beginners

Python Tutorial 1 – “Hello World”

Open up your Python Shell (I’m using Python 3.6.2)

All you need to do, on your Python shell, is write out exactly… print(“Hello World”)

This is calling the “print” function of Python, and we’re making it say “Hello World”

So the syntax here is pretty simple. All you need to do is write out print, add ( ) brackets with ” “ quotation marks inside, and between the quotations marks you spell what you want Python to print out.

Some examples…

print(“Hello World!”)

print(“How was your day?”)

print(“This is how you use the print function of Python!”)

These examples can be copied and pasted into the Python shell and used.


Written for my own study of Python as I journey to learn it. I’m following the instructions from this YouTube video, and this section of the tutorial begins at 4:09.

Python Tutorial for Beginners


Pasta Puns – Derek and Peter

“Peter, don’t eat with your hands!” Sheila, the mother, commanded her son, who is eating spaghetti with his hands.

“But mom, I’m not stroganoff to use a fork.” Peter laughed.

“The real Peter would never admit to not being stroganoff…you must be an impasta!” Derek hopped on the pun train.

“You’ve lost your noodle!” Peter responded.

“I bet you paid a pretty penne for that one.” Derek said.

“No way, puns are a part of my daily rotini.” Peter said.

“You look as dough you’re coming up with these on the spot!”

James is shaking his head. “Would you guys cut it out?” He asked with shake of his head.

Wheat a minute, we’re not done yet!” Peter and Derek said at the same time.

“Here we go agrain.” James deadpanned.

Stick-It Notes – Gus and Peter

Gus, father of the McWilliams children, walked to the kitchen for a bite to eat.

Recalling chocolate pie in the fridge made that his first stop.

He opened up the refridgerator and behold, half a chocolate pie. But there was a stick-it note on the plastic lid.

“Do not eat – Peter” is what it read.

There was also a note on the orange soda. “Do not drink – also Peter”

In fact, all of the food in the fridge had a stick-it note plastered onto it with a family member’s name on it.

Giving up on a snack, Gus decided to watch some TV. He plopped on the couch and picked up the remote.

It also had a stick-it note!

“I call the TV next – Derek” it read.

“You’ve got to be kidding me.” Said Gus.

The car keys, bathroom door, laundry, board games, video games, laptops, phones, EVERYTHING had stick-it notes stuck to them by various members of the McWilliams family, each claiming ownership as if the stick-it note prevented others from using whatever they’re stuck it.

And it worked so far…

Gus shook his head. “I know how to stop this.”

Peter walked in the house, a bag of fast food in his hands. “I need to stick-it note my ownership on these…”

He walked to the closet to grab a stick-it note but was shocked to see the package of stick-it notes had a note on it.

“These are mine now. – Gus/Dad”

“Darn it.” Peter said.