All language subtitles for 017 Python Primitive Data Types.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1

Yesterday you saw that we could use the Len function to get the number of

2

characters in a string. So for example, when I write Len,

3

hello and I print this out,

4

we end up with 5. There's 5 characters in the string hello.

5

Now here's a question.

6

What happens if instead of counting the number of characters in a string,

7

what if I put in a number instead and I wanted to know how many digits are in

8

this number? Now if I go ahead and run this code,

9

you'll see that it actually crashes.

10

I get a whole bunch of red text and it tells me that there is a type error and

11

something about the type int. So what is all of this about?

12

Well, in order to understand it, we first have to learn about data types.

13

Now on day 1, we already explored this data type called strings.

14

Now you're probably not going to be surprised to learn that there's a whole lot

15

more other data types out there.

16

And today we're going to explore some of the most important and some of the most

17

basic data types such as strings, integers, float, and booleans.

18

And we'll explore each of these in detail.

19

So go ahead and get hold of the day 2 start coding sandbox and go ahead and

20

fork your own copy of it. Now once you've done that,

21

let's take a look at some of the data types.

22

So we already learned about strings, right?

23

And we know that this is just a string of characters.

24

So the word hello is comprised of these five characters strung together.

25

And we always know that strings, when we create them,

26

we have to create them with these double quotes around.

27

Now because this is a string of characters,

28

we can actually pull out each character individually. So we could, for example,

29

instead of just writing hello, we can add some square brackets.

30

So take a look on your keyboard and see where those are.

31

And inside the square brackets, we can put the index or the position of the

32

character that we want. So, for example,

33

if I wanted to have the first character out of this word hello,

34

I would put zero right here.

35

And if I go ahead and print what this actually will give me,

36

you'll see that you get capital H because that is the first character of this

37

string.

38

And it's really important to remember that programmers always start counting

39

from zero because we work with binary, zeros and ones.

40

So whenever you want to get hold of the first character or the first of

41

anything, it always is at zero.

42

So this method of pulling out a particular element from a string is called sub-

43

scripting. And the number in between the square brackets determines

44

which character you're going to pull out,

45

and it just goes up from zero to one to two and so on and so forth.

46

So whenever you get a result that's just off by one,

47

then remember to check whether if you've started counting from zero or if you

48

started counting from one.

49

Now you can of course extend this and get hold of the last character.

50

So pause the video and see if you can change the code so that 'o' gets printed

51

out here. All right,

52

so this is a simple as simply counting from zero, one, two, three,

53

four. So if we change this to four and we run our code,

54

then you'll see that 'o' gets printed instead of the H.

55

So by using these square brackets and putting a number inside,

56

we're able to dissect our string and pull out individual characters as and when

57

we need it.

58

And this will come in really handy in a lot of the programs that you'll write in

59

the future.

60

Now it's important to remember though that just because I can write a number

61

like "123",

62

as long as it's kept inside these double quotes,

63

then this is not treated as a number by the computer.

64

It's treated just as any other piece of text. You can't, for example, say,

65

um, what is "123" + "345".

66

If I try to print this, what do you think will happen?

67

Do you think it will give me 123 + 345

68

in the traditional sense,

69

like calculating it or do you think it'll do something else? All right,

70

let's hit run and we get 123345.

71

So it's basically just concatenated these two strings together,

72

just as we have done with other strings like hello and world, right?

73

Because it sees the datatype of these two pieces of data as strings.

74

When we use the plus sign,

75

it will actually just concatenate these two things instead of doing a

76

mathematical operation. Now if we want to do that,

77

then we actually have to declare our number as a number data type.

78

So one of the most common that you'll see is called an integer.

79

So this is programming lingo for just whole numbers, numbers

80

without any decimal places.

81

And in order to create an integer or declare an integer data type,

82

all you have to do is just write the number without anything else.

83

So now if I just write the numbers, 123 + 345

84

and then I go ahead and print this,

85

then you'll see that we actually get 468.

86

So it's actually being calculated because I've got actual numbers instead of

87

strings.

88

Just as we have some useful things that we can do with strings.

89

There's some really handy things that you can do with integers.

90

Commonly when we write large numbers,

91

at least in the UK or in the US, we'd like to put commas in between the

92

thousands.

93

So when we think of large numbers with these commas in between to split it into

94

an easier to understand number. In Python,

95

we can replace those commas simply with underscores and it will be interpreted

96

by the computer as if you had written this.

97

So the computer actually removes those underscores and ignores it.

98

The benefit is just for us humans to be able to visualize it more easily.

99

So I mentioned that all whole numbers

100

no matter if they're positive or negative, are called integers in programming.

101

So what do you call it when you actually have decimal places? Well,

102

they are called a float and this is short for a floating-point number.

103

So for example, if you had um, the numbers of PI,

104

you have 3.14159

105

and this, because it has a decimal place, is now a float data type.

106

So if you think of the decimal point as being able to float around the number

107

because it could occur at any point,

108

then you've got yourself a floating point number.

109

Now the final data type is something called a boolean.

110

And this is very simple. It only has two possible values,

111

true or false.

112

Now note how these values always begin with a capital T or capital F and they

113

don't have any quotation marks around them or anything.

114

So this is actually a data type which is going to be used a lot in your programs

115

to test if something is true,

116

if something is false and for your program to respond accordingly.

117

So we're going to be using this a lot more in the future.

118

Now that you've seen a lot of the basic data types, strings, integers, floats,

119

and boolean,

120

I want you to head over to the next lesson where I've got a quiz for you to see

121

if you've made this knowledge your own. So head over to the quiz and give it a go.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.