1.10 Python Basics Part 1 - IP

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
2 hours 57 minutes
Difficulty
Beginner
CEU/CPE
3
Video Transcription
00:00
>> Hello everyone, and welcome back to intro to
00:00
Python here on cybrary on demand.
00:00
You are watching Lesson 7,
00:00
the final lesson of Module
00:00
1 and you're watching it here with me,
00:00
your instructor Joe Perry.
00:00
Today in Lesson 7,
00:00
what we're going to cover are the four Python datatypes.
00:00
There're actually more than four Python data types,
00:00
but these are the four we're going to worry about,
00:00
strings, numbers, lists, and dictionaries.
00:00
We're going to try and do this all in one fell swoop.
00:00
We're going to just run through each of them.
00:00
Each of these, by the way,
00:00
is actually going to be the subject of
00:00
its own lesson in Module 2.
00:00
Strings, numbers, lists, and dictionaries all going to
00:00
deep dive lesson in Module 2.
00:00
Don't worry too terribly much if you don't
00:00
necessarily know how to
00:00
use all of them at the end of this video,
00:00
most of them are just there so that
00:00
we know what they are and to
00:00
familiar with them when we see
00:00
them in the code for the next module.
00:00
The first example, strings,
00:00
you may remember from our variables lesson,
00:00
variables are Tupperware for your brain.
00:00
They're just places to store data.
00:00
Strings and Python are denoted rather by using quotes,
00:00
either double or single quotes.
00:00
In this case, you can write something, for example,
00:00
we are in the knights who say ni.
00:00
If you don't know that reference that as
00:00
a money Python reference.
00:00
In fact, in the name of the Python programming language,
00:00
if I didn't mention it before,
00:00
is actually a reference to Monty Python.
00:00
You're going to see a lot of jokes
00:00
about Monty Python when you're going
00:00
through code and documentation
00:00
and tutorials for this language.
00:00
X is now the string,
00:00
we are the Knight's who say, ni,
00:00
we can print x as we've done with
00:00
Hello World and it will work just fine.
00:00
In fact instead of doing prints, Hello World,
00:00
[NOISE] we could have
00:00
simply set that string equal to a variable
00:00
[NOISE] and printed it that way.
00:00
Now it's worth noting that in a lot of cases,
00:00
people will want to just print the string directly.
00:00
It's not a terrible situation to do that in Python.
00:00
Python's are relatively memory safe language,
00:00
so you can usually get away
00:00
with directly printing strings.
00:00
But when you're working with some modules,
00:00
for example, SQL,
00:00
you usually want to interpret it
00:00
through a variable because there are ways
00:00
that you can implement security by
00:00
using the variable instead
00:00
of just using the string directly.
00:00
Then of course, having variables where people can
00:00
store input strings is always essential.
00:00
Wrong command, those are strings.
00:00
Now we're going to go ahead and we're going to talk
00:00
about numbers in Python.
00:00
Numbers in Python work
00:00
exactly the same way that strings do,
00:00
except that they are created without quotes.
00:00
If you're familiar with other languages,
00:00
you may know that in,
00:00
for example, C there are
00:00
a whole bunch of different types of number.
00:00
There are integers, there are floats.
00:00
There are bools which are actually
00:00
just numbers and C. There are bools,
00:00
there are longs, there are doubles,
00:00
there are words, there are quad words.
00:00
All sorts of different types of number in Python,
00:00
those are all abstracted out and you just have numbers.
00:00
You can have z equals 1.24,
00:00
you can have w equals 14/2 anything.
00:00
Of course that will actually evaluate
00:00
out and just perform seven.
00:00
Now you'll notice that that seven has
00:00
a decimal like the 1.24 did,
00:00
but neither of these numbers had that.
00:00
That's because division in Python automatically
00:00
assigns a float under the hood.
00:00
It's still usable as a normal Python number,
00:00
but you will see the decimal place because Python
00:00
is interpreting it as a float,
00:00
which is an integer with decimal places.
00:00
You can do math and Python.
00:00
I actually often use Python
00:00
just for math because it's often
00:00
faster than finding the calculator and opening that up.
00:00
For example, seven to the 13th power,
00:00
you can find what seven star, star 13.
00:00
You can do normal addition.
00:00
Not what I meant to do there.
00:00
You can do subtraction, and of course,
00:00
you can store the result of these things in variables.
00:00
Numbers in Python, pretty straightforward.
00:00
You're going to use those all the time as I mentioned,
00:00
they're often used for control values or
00:00
to interpret menus or for other things.
00:00
But that's all numbers are in Python.
00:00
Now, in the next video,
00:00
because we're going to run up against our time here,
00:00
in the next video, we're going to discuss
00:00
the next two Python datatypes,
00:00
lists and dictionaries and those are
00:00
two abstracted data types
00:00
we're going to spend a little bit of time on.
00:00
Thank you for watching. As always,
00:00
I'm your instructor Joe Perry.
00:00
I'm very happy to have you here in
00:00
intro to Python on cybrary on demand.
Up Next