All language subtitles for 03_operators-and-operands.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
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
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

So far we've seen simple expressions like 100,

"Hello world" or 3.14.

These are all literal expressions where the value is the same as the expression itself.

But expressions are like building blocks that can be

combined to form larger and more complicated expressions.

Operators are one way to combine expressions.

The first operator that we'll learn is the addition operator.

In order to use it, we write something like print out 100 plus 200.

When I run this code note that I get the value 300.

So, when we execute a print statement then rather than printing out the expression

itself the expression here being 100 plus

200 then we print out the value of that expression.

So, this expression has

a value of 300.

Now, this expression uses the addition operator.

The addition operator which is done using the plus sign expects one expression to

the left and one expression to the right.

What it does is it computes the value of the expression to

the left and the value of the expression to the right.

It adds up these two values,

and then the value of this overall expression

is the value of this expression plus the value of this expression.

So, in the case of 100 plus 200,

we add the value 100 plus the value 200,

and the value of this overall expression ends up being 300.

Remember that whenever we call print,

we print out the value,

not the expression itself,

and so 300 gets printed in our output.

Beyond the addition operator,

python includes many other kinds of operators.

So, there's subtraction.

So, when I print out the value of five minus two then we get three.

If we reset our code here there's also multiplication.

Multiplication is done using the star symbol.

So, when we print out the value of the expression two times four then we get eight.

There's also division.

So, when I print out ten divided by three,

so division is done using the slash symbol.

When I print out the value of this expression then it's ten

divided by three which is 3.3 repeating.

In addition to addition, multiplication, division,

and subtraction, Python include some other kinds of operators.

So, you'll notice here that when we take ten divided by three,

we had two integers ten and three and we got a float as a result.

Sometimes we don't actually want that remainder.

So Python also includes truncated division which leaves out the remainder,

so that we get three back,

and it also includes the modulo operator.

So, if I say ten and then percent sign three,

this is the modulo operator,

so it gives me the remainder of ten divided by three, which is one.

Python also includes exponentiation.

So, if I print four star star two,

then this expression is like saying four to the power of two or four squared.

So, the value of this expression is four squared which is 16.

When executing code, python follows

the normal order of operations that you might be used to in math.

So, at highest precedence is whatever is in parentheses,

and then below that is exponentiation.

So, that would be something like four to the power of two.

Below that there is multiplication, and division.

So, that would be something like two times four,

and then below that there is addition and

subtraction, two plus three.

So, what this means is that suppose that we wanted to compute

the average of two numbers 10 and 20.

So, if we wanted to compute the average of these two,

which should be 15,

then we might intuitively write something like 10 plus 20 divided by two.

Now if I run this code,

you'll note that I get 20.0 rather than 15,

which is the actual average.

The reason is that Python because division is higher in precedence than addition,

when computing the value of this expression then Python first computes

the value of 20 divided by two and gets 10.0.

Then it adds 10 plus 10.0,

and gets the value 20.0.

If instead we wanted to first add 10 and 20,

and then divide by two,

then we could add parenthesis around 10 and 20.

So, I would say print out 10 plus 20 in parentheses divided by two.

Now what Python is going to do is it's first going to add 10 plus 20

to get 30 and divide by two to get 15.0.

You can see that now we're correctly getting the average of 10 and 20. See you next time.

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