All language subtitles for 028 [Interactive Coding Exercise] Odd or Even_ Introducing the Modulo.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

All right guys, it's time for yet

2

another code challenge to test and see if you've learned what was covered in

3

previous lessons. So head over to the assignment

4

that is a day 3.1 odd

5

or eve. Have a read of the instructions and try to see if you can create a

6

program that checks whether if a number that you input in the console is odd

7

or even. Now the thing to remember here though

8

is that we're introducing something called the modulo

9

and you can create the symbol by simply typing the percentage sign. Now,

10

what the modulo does is it will divide a number

11

say seven by another number

12

let's say two, and then it will give you the remainder of that division.

13

So seven divided by two, seven split into portions of two is two plus two plus

14

two plus one, right?

15

So seven divided by two can be divided three times with a remainder of one.

16

And that's what the modulo gives you.

17

So you can also type code straight into the console like I'm going to do now;

18

7 % 2. It gives me 1.

19

Now it's the same thing if you try to divide by other numbers,

20

let's say 7 % 3. Well,

21

that is three plus three plus one, right?

22

So seven modular three will also give me one.

23

So this is a way for us to divide a number by another number and get the

24

remainder.

25

And you're going to be using this modular to solve this code challenge.

26

Have a read of the instructions,

27

have a look at the examples and see what it is that we're expecting to be

28

printed in the console here.

29

And then go ahead and write your code and see if your output matches what it is

30

that we're expecting. So 56 should be even,

31

so you should be printing "This is an even number" based on that input.

32

Pause the video now and give this code challenge a go.

33

All right.

34

So I mentioned that the modulo gives us the remainder, right?

35

So what do we know about even numbers? Well even numbers they're always divisible by

36

two. If we pick any even number, say 54,

37

and then we do modulo two, so 54 divided by 2,

38

it should always give us zero

39

as long as that first number is even so 68 % 2

40

again it zero.

41

But then when we come across an odd number, say 53 % 2,

42

then this is now going to give us 1.

43

We can use our code to check for when the result is zero,

44

in which case it's a even number. And when the result is one,

45

in which case it's an odd number. If you have gotten stuck until this point,

46

and this is a really great time to pause the video again and go back and give it

47

another go. And then we'll go through the solution together.

48

We can simply write an if statement to check if the number that was inputted is

49

divisible by two with zero remainder.

50

Well, in this case, then we can pretty much be sure that this is an even number,

51

because as we've shown, all of the even numbers when they divide by two,

52

there's always no remainder. So in this case, let's add a colon.

53

We can print pretty confidently that this is a even number.

54

Now,

55

what about the cases where the number when divided by two is not equal to zero?

56

Well, then it's probably going to be an odd number. So in this case

57

we can use an else statement to catch that.

58

And when we have an odd number, we'll simply print

59

this is an odd number.

60

So that's it. Just four the lines of code using what we've learned about if, else,

61

and also the comparison operator. Now,

62

if you got stuck on this and you needed to watch the solution,

63

then I recommend really going back to your code and playing around with it so

64

that you can get the code to work. And then try and see if you can test if a

65

particular number is cleanly divisible by three by four by five,

66

and then see if the final program actually works in the way that you expect it

67

to. But once you're ready,

68

head over to the next lesson where we're going to talk about even more complex

69

ways of using if and else statements. So for all of that

70

and more, I'll see you there.

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