Hello.
Welcome back.
So this was our last project where we saw how to deal with things like indentation and how to print
a simple statement.
And this lesson we should look at the variable types.
What I'm going to do is I'm going to create a new project from this one by clicking the file and then
I'll just click new over here and then I can come over here and say save all press controls and I'm
going to call this number one on this call.
Variables like this.
And once that's done I can close this old one actually and I just explain this a bit.
Right.
So let's get started.
So one other thing you should know about Python is it is completely object oriented and it's not statically
typed.
And what this means is we do not need to declare variables before using them or even declared the other
types.
We can just assigned anything to a variable and we don't need to declare what it's an integer overflow
to string a character etc. every variable in Python is treated as an object.
So let's see what I mean.
And basically python like in most programming languages support two types of numbers the integer in
the float.
Let's see.
So let's say we want to declare a number a normal integer number.
There are ways of doing that.
We could say num num.
And of course 10.
And this has got nothing to do with this.
In any case doesn't tell python I want an integer I'm just saying this variable of course 10.
I could have said X Y or boy of course 10 and it would be assigned to boy and we can print that to see
print num end.
Does the name of the variable to once that's done of press control is and then run from over here and
I can see it's print at 10.
Just like the for a float we can just declare it in the same way I can see num on the school float because
something like eight point zero and then I can come down in print floats as well Naam on the score float
like this control is click here and then run module you can see it's printed zero point eight as well.
So another way we can define a float is to actually cast it to a float and let's see what I mean by
cost to a float I can come here and see and num float to it cause float and over here or just passed
an integer type such as nine and let's see what happens when I use the float function float nine and
I'll print the variable name is let's just be consistent by putting an underscore here the verbal name
is num float 2.
So I just pass the variable name here.
Now on this call float to oppress control as to save.
Click here to run that's going to see it's printed numb flow to us nine point zero or do I passed nine
there.
So this another way of typecast in a an integer to a float.
Very simple very straightforward.
Right.
We can also assign things like strings to integers without even declaring them.
For instance I can say greeting of course Hello I can use a single quotation Hello like this and I can
see print greeting
and control as I run this experiment would actually be better run over here in the show so that we can
just see the resort.
But I want you to keep records of all the various lessons.
That's why we've created a new file in storing it so that we can change and perhaps you may need to
revise in the future.
So anyway as you can see it's printed hello here using a single quotation mark.
So I'm going to declare another string variable.
I can see response because.
This time we can use a double quotation and we can see high and we can come down here and say print
into brackets response like this and then I press controls to save a click over here run module we have
response high.
So we've got options we can use this single quotation or the double quotation so let's see other things
that we can do we with strings we can concatenate strings just by using a simple addition sine like
great and plus response will give us Hello Hi let's make something sensible out of that.
For instance less a variable greeting one cause less good let's say we want to say good afternoon and
then creating 2 which is the second part of the greeting could be afternoon afternoon like this and
we can see a complete greeting.
These are all variables complete on the school greeting because we can see creates in one
plus creates and two and we can come down here and see print and then over here complete greeting and
let's see what we get for this as a type of over here her request an E so I press control as to save
I click here run and then run module we have Hello hello.
Afternoon because we forgot the one here.
So it's use in this is that so I'll put a one here and then we'll have greeting one plus greeting to
control less click over here click Run mode.
Good afternoon says and we can add space between if we want Crete and one plus space and then plus greet
into and it's going to be good space.
Afternoon Oh good afternoon is one word and there's a typo in afternoon anyway you get a point right.
So we can you know deal with strings like this.
Right.
So this will there's for this lesson and one thing I'll point out you don't need to know the entire
basics of Python before doing real stuff like DSP machine learning and other things.
No you just need to know how to understand a variable is manipulate them understand how to create things
like loops and functions as soon as you are done with that you need to get off the basics and start
doing something much more exciting and practical because that's the only way you're going to learn the
language because the basics tend to get boring after some time.
So this all there is for this lesson and you have any questions at all.
Send me a message or leave in the questions area and if you're finding this course useful please take
some time off to leave a review and of course I shall see you in the next lesson.