Welcome to PyBeginners ā your go-to place to learn Python programming the easy way! š
Whether you're starting from scratch or revisiting the basics, this channel is built just for YOU. We break down Python concepts into bite-sized, beginner-friendly videos using real-life examples, everyday language, and fun visuals.
Think of PyBeginners as your coding buddy ā here to help you:
ā
Understand the why behind every concept
ā
Build confidence, one small step at a time
ā
Learn coding without feeling overwhelmed
š Check out more learning resources:
š Blogs: https://www.pybeginners.com/
š¼ LinkedIn: https://www.linkedin.com/newsletters/pybeginners-7267881715929415681/
š New videos every week ā covering Python basics, hands-on exercises, projects, and career tips!
š Subscribe, join the PyBeginners family, and let's make Python simple together š»š¬
#LearnPython #PyBeginners #PythonForBeginners #PythonMadeEasy
In this video, we're talking about **data types** in Python, so you can understand how Python knows what kind of **data** you're using, including if it's a **boolean**. This video is perfect for **python for beginners** who need some help learning **programming**!
Show More Show Less View Video Transcript
0:00
hey guys welcome back to this channel If
0:02
you're new then welcome to this channel
0:03
Well I'm back with one more interesting
0:05
Python video And today we are going to
0:08
talk about data types in Python
0:12
So just one quick question Have you ever
0:15
wondered how Python actually knows what
0:18
kind of data you're working with
0:21
like how does it know if you're storing
0:23
a number some text or whether is that a
0:27
true or false
0:32
well that's what today's video is all
0:34
about which is data types in Python And
0:36
if you're new to coding this is one of
0:38
those topics that makes everything else
0:40
suddenly click So let's take our time
0:43
and go through it properly with simple
0:45
examples and real world comparisons and
0:48
a few tips you'll thank yourself for
0:50
later So let's dive in
0:54
All right first things first What
0:56
exactly is a data type
0:58
well when you create a variable in
1:00
Python say it like for example x= to 10
1:04
and Python needs to know what kind of
1:07
value it's working with Is it a number
1:10
is it some text or is it just true or
1:14
false so that's where data types come in
1:17
So they tell Python hey treat this value
1:21
like a number or hey Python this one's
1:24
just a string of characters or this is a
1:27
simple true or false situation So every
1:30
single value in Python has a type and
1:33
based on that type Python decides what
1:36
operations you can perform on it
1:41
So let's start with most basic thing
1:44
which is integers
1:48
We can also uh call it we use integers
1:51
for short numbers like these could be
1:53
the whole numbers no decimals just clean
1:56
simple counting numbers So here is an
1:59
example You can also write like for
2:02
example age equal to 50
2:09
or you could write score equal to 100
2:15
and level
2:17
equal to minus 5 These are just the
2:19
basic examples like how we can store
2:21
integer values in the variables So it
2:24
could be age equal to 5 15 score equal
2:27
to 100 and level equal to minus 5 So
2:30
here age score and level are all
2:32
integers They could be positive negative
2:35
or even zero
2:38
All right Python I'm storing a full
2:40
number Nothing fancy So this is what
2:43
you're going to tell And you can also
2:46
use integers for counting the lives in
2:48
games or you can track your own age And
2:53
you can even keep you know keeping your
2:55
score 100
2:57
and number of items in the cart
3:00
something like that It's very it's very
3:02
simple
3:05
Okay
3:09
Okay Now let's talk about floats
3:13
So now this one's not about swimming I I
3:16
know that floats is all about swimming
3:19
but not here So it's a short form for
3:22
floating point numbers Basically these
3:25
are the numbers that have a decimal
3:28
point like if you see here this one
3:32
I can give you more examples or you can
3:34
say
3:37
floating
3:38
or float numbers
3:43
You can do something like weight You can
3:46
add the value in float
3:49
and it could be maybe temperature
3:53
which is minus
3:55
36.7
3:58
or even 2.5
4:00
and it could also be a price which is in
4:03
decimals most of the time you see 99.99
4:07
So if your values has a dot so Python
4:11
will treat that as a decimal number that
4:15
as a float number So you would use
4:17
floats for temperature readings money
4:20
and prices percentages any kind of
4:24
measurement that is not a whole number
4:26
So just remember no decimal it means int
4:31
If there is a decimal then it is float
4:35
Now let's talk about shrinks
4:39
So now this is where things get fun
4:42
which are strings because these are
4:43
basically any kind of text whether it's
4:46
a name or a sentence or even an even
4:49
emojis In Python a string is wrapped in
4:52
quotes It is it could be even in single
4:54
quotes or in double quotes It doesn't
4:56
matter Like for example
5:07
name equal to
5:10
John
5:12
and greeting
5:14
equal to
5:17
hello
5:20
world
5:25
or I could give comma here
5:27
And you can also give emoji but I have
5:30
to copy paste it from the you know
5:34
wherever you find emojis you can just
5:36
copy paste it there So whether hello or
5:39
123 main street or any emoji which is
5:42
inside the quotes python treats it as a
5:46
string
5:48
So if you ever forget and try to store
5:51
text without quotes Python's going to
5:54
throw an error like hey I don't know
5:57
what do you mean like for example
6:00
it'll be really crazy on you See it's
6:02
already saying that there's an error so
6:05
world is not defined So Python is
6:08
thinking that this might be any variable
6:11
and this might be any variable So if you
6:13
give in quotes then Python will think
6:16
like okay this is a string and I don't
6:18
have to think about that it's I just
6:21
have to display just like that with
6:23
whatever inside the quotes
6:26
So you will use strings literally all
6:29
the time It could be when you're
6:31
displaying the messages to the users or
6:34
storing names or addresses or giving the
6:36
feedback or when you're dealing with
6:39
chat bots or interfaces or when you're
6:41
dealing with user inputs all are string
6:45
heavy
6:46
So this is when you work with strings
6:50
Always remember whenever you're giving
6:52
anything in the quotes then it will be a
6:55
string You can also give a number as a
6:58
string it will take it as a string It
7:00
will not take it as a number
7:02
So that's the difference
7:05
And now we have one more data type last
7:08
but not least because we have to talk
7:12
about booleans which is true or false So
7:16
that's just these two options It's a
7:18
Python's way of doing yes or no logic
7:22
Like for example
7:26
is logged in you'll use true or false
7:31
here right
7:33
so true or is admin
7:38
I'm sorry
7:44
then again it'll be true
7:46
or maybe game over
7:51
could be false
7:55
So you'll use booleans in all sorts of
7:58
situations like checking if a user is
8:01
logged in or not or whether a form is
8:04
complete or not or if the game should
8:07
restart
8:08
or if a light switch is on or off So
8:12
anytime you're working with logic like
8:14
is this condition met
8:20
is this condition
8:24
met
8:26
so then at that time you are using
8:28
booleans which are nothing but true or
8:31
false yes or no So booleans are remember
8:34
keep that in mind these are case
8:36
sensitive like you have to write them
8:39
with t capital and f capital then only
8:42
python will take if you give small t
8:45
then it will take it as a variable So
8:48
always remember booleans are case
8:50
sensitive which means you have to write
8:52
the first letter of that true or false
8:55
in capitals
8:58
All right
9:02
Now
9:04
how to check the data type like how to
9:06
check what data type is running in the
9:10
program All right Now here's a cool
9:13
little trick Let's say you're not sure
9:15
what kind of data is inside a variable
9:18
Maybe it came from a user or maybe from
9:21
some other file that you don't know So
9:24
you can ask Python using a function
9:27
called type
9:33
So you have to always use this function
9:36
when whenever you want to check what
9:38
data type is running in the program
9:41
Maybe the data that you are getting you
9:43
are not sure what data is going on there
9:46
It could be string it could be number
9:49
or it could be a float
9:52
So like for example I think I have
9:54
already explained this in the previous
9:56
classes itself but like for example if x
10:00
equal to 42 and you want to check
10:01
whether x is a string or is that a
10:05
integer or is that a float you can
10:08
always type this x
10:12
and you can directly just print it
10:18
Now you will see class
10:24
which is int So it is saying that it is
10:26
an integer data type Like if you give
10:29
the same thing in a quotes then it will
10:31
take it as a string and now you will see
10:33
the output as str which is nothing but
10:36
string So this will be really helpful
10:39
when you're debugging when you're
10:41
checking where where there is something
10:44
wrong in the code when you want to check
10:46
what's going wrong in the code
10:49
All right that was your crash course in
10:53
data types in Python Let's quickly recap
10:58
So we have integers which are whole
11:02
numbers and we have floats which are
11:05
numbers with decimals and we have
11:08
strings for text or characters and we
11:10
have boolean which are true or false If
11:12
you master these four data types you are
11:15
already halfway to becoming a confident
11:18
Python developer Seriously Next up we
11:22
going to learn how to get input from
11:25
users and print output back to the
11:28
screen which is how you start making
11:30
your code interactive and fun If this
11:34
video helped go ahead and smash that
11:36
like button subscribe to the channel and
11:39
hit the bell icon so you don't miss the
11:41
next episode Thanks for learning with me
11:43
and I'll see you in the next

