All language subtitles for 7. Comparison Operators

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
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 Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,690 --> 00:00:06,000 Hello everyone and welcome to lecture on comparison operators in this lecture we're going to learn how 2 00:00:06,000 --> 00:00:10,530 to use comparison operators to compare variables that return logical values. 3 00:00:10,530 --> 00:00:13,950 Let's go ahead and see some examples by jumping to our studio. 4 00:00:13,950 --> 00:00:18,340 All right let's start off by just going through each of the comparison operators. 5 00:00:18,360 --> 00:00:20,340 You're pretty self-explanatory. 6 00:00:20,340 --> 00:00:23,260 So we'll just use simple integers to explain them for us. 7 00:00:23,520 --> 00:00:28,820 Let's say you wanted to get a comparison of five is greater than six. 8 00:00:28,820 --> 00:00:30,970 This should return a logical value. 9 00:00:30,990 --> 00:00:38,290 In this case false to 1 do less then it's just going to be the reverse less sense so 5 less than six 10 00:00:38,290 --> 00:00:39,160 . 11 00:00:39,420 --> 00:00:40,670 True. 12 00:00:40,830 --> 00:00:44,170 Now you can also do greater than or equal to or less than or equal to. 13 00:00:44,370 --> 00:00:52,260 By using something that looks like this or something that looks like this looks for greater than or 14 00:00:52,260 --> 00:00:53,500 equal to. 15 00:00:54,210 --> 00:00:58,890 So you just tack on an equal sign to the less than or greater than sign. 16 00:00:58,890 --> 00:01:02,930 Now you can also do comparisons for equality or inequality. 17 00:01:03,090 --> 00:01:10,740 You can do that with equality for two equal sides so if you want to check let's say if two was equals 18 00:01:10,740 --> 00:01:16,050 equals to three that's going to be a CheckFree quality in this case it's false. 19 00:01:16,050 --> 00:01:20,340 If you just use one equal sign you should get some sort of error because you're basically trying to 20 00:01:20,340 --> 00:01:21,680 do some sort of assignment here. 21 00:01:21,790 --> 00:01:23,180 Is getting it to. 22 00:01:23,250 --> 00:01:26,530 Just remember it's two equal signs for equality. 23 00:01:26,580 --> 00:01:28,870 Do you want to test for any. 24 00:01:29,070 --> 00:01:37,970 You use an exclamation points or exclamation mark with an equal sign so as to not equal to four. 25 00:01:38,070 --> 00:01:42,060 That's true is to not equal to two. 26 00:01:42,120 --> 00:01:43,220 That's false. 27 00:01:43,530 --> 00:01:46,430 And again for equality just two equal signs. 28 00:01:46,530 --> 00:01:47,120 All right. 29 00:01:47,310 --> 00:01:52,960 Something they should pay close attention to is your spacing out when comparing numbers. 30 00:01:53,130 --> 00:02:02,330 Because if you remember correctly the assignments operator for R is this arrow symbol. 31 00:02:02,610 --> 00:02:05,920 So let's say I want to assign 2 to V. 32 00:02:05,940 --> 00:02:07,190 That's how it works. 33 00:02:07,410 --> 00:02:13,470 But let's say I actually have the equal to 2 and I want to compare V. 34 00:02:13,860 --> 00:02:18,300 I want to ask if the is less than negative 1. 35 00:02:18,300 --> 00:02:22,760 Notice here how the spacing is going to play a major role here. 36 00:02:22,770 --> 00:02:27,610 Here I am saying is be less than negative 1 and the answer is false. 37 00:02:27,640 --> 00:02:34,110 If I'm not paying close attention to my spacing and do something like this you're actually going to 38 00:02:34,110 --> 00:02:37,860 do a reassignments of the so that you'll save the. 39 00:02:37,950 --> 00:02:40,580 A sign one value. 40 00:02:40,620 --> 00:02:42,090 So notice the difference here. 41 00:02:42,090 --> 00:02:47,640 This is kind of important otherwise you may mess up your code later on if you have some variable name 42 00:02:47,640 --> 00:02:48,920 . 43 00:02:49,620 --> 00:02:51,410 Just go ahead and put in. 44 00:02:51,570 --> 00:02:57,840 Let's say my VCR and you're trying to do a comparison to a negative number. 45 00:02:57,840 --> 00:03:00,490 Make sure your spacing makes sense for that. 46 00:03:00,690 --> 00:03:06,480 So you always want to make it very clear that you're comparing to a negative number. 47 00:03:06,480 --> 00:03:10,200 Or if you're trying to do some sort of reassignments 48 00:03:14,550 --> 00:03:21,240 so please pay close attention here to the differences of the reassignments versus the comparisons. 49 00:03:21,270 --> 00:03:23,560 OK so that's just a little hiccup. 50 00:03:23,570 --> 00:03:24,840 You may find in the future. 51 00:03:24,870 --> 00:03:29,340 These should probably be paying attention to if you're ever doing some sort of less than comparison 52 00:03:29,340 --> 00:03:32,040 with negative numbers living on. 53 00:03:32,190 --> 00:03:36,030 I want to show you now how you can use comparison operators with vectors. 54 00:03:36,300 --> 00:03:41,940 So when you use a vector with a comparison operator instead of returning just a single logical true 55 00:03:41,940 --> 00:03:42,870 or false value. 56 00:03:43,050 --> 00:03:46,590 It's actually to return an entire vector of logical values. 57 00:03:46,590 --> 00:03:47,640 Let's go ahead and show this. 58 00:03:47,640 --> 00:03:55,170 By creating a vector We'll start by just using the combined function to create a vector of 1 2 3 4 5 59 00:03:55,170 --> 00:03:56,410 . 60 00:03:56,580 --> 00:04:01,780 Now let's say I wanted to compare the less than 2. 61 00:04:01,800 --> 00:04:02,730 What's this going to do. 62 00:04:02,730 --> 00:04:03,260 It's going to do. 63 00:04:03,330 --> 00:04:06,000 Elements by elements comparison. 64 00:04:06,240 --> 00:04:12,030 So it's going to compare all those elements and then return a vector of logical values with the index 65 00:04:12,030 --> 00:04:13,800 referring to the comparison. 66 00:04:13,830 --> 00:04:15,400 So was one less than two. 67 00:04:15,420 --> 00:04:15,970 That's true. 68 00:04:15,990 --> 00:04:16,950 Was 2 less than 2. 69 00:04:16,950 --> 00:04:19,490 That's false false false etc.. 70 00:04:19,620 --> 00:04:22,960 So let's say I wanted to check for equality. 71 00:04:24,570 --> 00:04:29,130 I can do this and it's actually going to return a vector of logical values. 72 00:04:29,340 --> 00:04:34,320 Later on we're going to see how we can Easy's vector comparisons to actually select parts of the vector 73 00:04:34,320 --> 00:04:34,440 . 74 00:04:34,560 --> 00:04:37,190 Which is why we're explaining them now. 75 00:04:37,600 --> 00:04:39,760 OK so that's really all there is. 76 00:04:39,810 --> 00:04:44,830 As far as comparison operators should be pretty straightforward and self-explanatory. 77 00:04:44,970 --> 00:04:48,730 You just have the greater than sign. 78 00:04:49,440 --> 00:04:55,820 You have the less than sign you have greater than or equal to less than or equal to now. 79 00:04:55,860 --> 00:05:01,410 Checks for equality of two equal signs checks for inequality of an exclamation sign with an equal sign 80 00:05:01,420 --> 00:05:01,640 . 81 00:05:01,950 --> 00:05:08,420 And then you can also use the same comparison operators on entire vectors against a single number. 82 00:05:08,790 --> 00:05:14,850 All right last thing I want to mention is that you can actually do element by element comparisons for 83 00:05:15,090 --> 00:05:16,370 multiple vectors. 84 00:05:16,410 --> 00:05:19,720 So let's say I want to compare vector against another vector. 85 00:05:20,190 --> 00:05:21,720 So I have my first vector. 86 00:05:21,770 --> 00:05:27,490 The let's go ahead and assign the two use combined function. 87 00:05:27,510 --> 00:05:37,860 Now let's go ahead and make 10 20 30 40 50 so I can actually compare the one on an element by element 88 00:05:37,860 --> 00:05:41,720 basis to the two. 89 00:05:41,730 --> 00:05:47,070 So I say go ahead and say it is whereas V less than the two. 90 00:05:47,460 --> 00:05:50,220 So you get all five trues which makes sense. 91 00:05:50,220 --> 00:05:56,340 The in every single index location when you compare it on an element bilat basis to be 2 is always less 92 00:05:56,340 --> 00:05:57,150 than the two. 93 00:05:57,270 --> 00:05:58,390 So one is less than 10. 94 00:05:58,400 --> 00:05:59,390 Two is less than 20. 95 00:05:59,430 --> 00:06:00,450 Cetera. 96 00:06:00,450 --> 00:06:03,120 So just like when you compare it to a single value. 97 00:06:03,330 --> 00:06:06,120 A vector by vector comparison operation. 98 00:06:06,240 --> 00:06:12,310 Basically also works the same way in returning a vector full of logical boolean values. 99 00:06:12,630 --> 00:06:15,360 Ok that's it for this lecture. 100 00:06:15,360 --> 00:06:20,670 Again just a quick reminder make sure you pay attention if you're ever doing a comparison that's something 101 00:06:20,670 --> 00:06:27,330 similar to less than a negative number so you're not actually doing a reassignments. 102 00:06:27,570 --> 00:06:29,350 All right thanks everyone. 103 00:06:29,370 --> 00:06:30,180 I'll see you at the next lecture 9823

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