Comparison Operators

3 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$39.99
List Price:  $79.99
You save:  $40
€34.34
List Price:  €68.70
You save:  €34.35
£29.75
List Price:  £59.51
You save:  £29.76
CA$55.26
List Price:  CA$110.54
You save:  CA$55.28
A$61.34
List Price:  A$122.71
You save:  A$61.36
S$51.56
List Price:  S$103.13
You save:  S$51.57
HK$311.87
List Price:  HK$623.83
You save:  HK$311.95
CHF 32.19
List Price:  CHF 64.39
You save:  CHF 32.20
NOK kr403.80
List Price:  NOK kr807.72
You save:  NOK kr403.91
DKK kr256.36
List Price:  DKK kr512.80
You save:  DKK kr256.43
NZ$68.25
List Price:  NZ$136.51
You save:  NZ$68.26
د.إ146.86
List Price:  د.إ293.76
You save:  د.إ146.90
৳4,863.12
List Price:  ৳9,727.46
You save:  ৳4,864.33
₹3,524.96
List Price:  ₹7,050.81
You save:  ₹3,525.84
RM169.05
List Price:  RM338.15
You save:  RM169.10
₦61,064.73
List Price:  ₦122,144.73
You save:  ₦61,080
₨11,267.18
List Price:  ₨22,537.18
You save:  ₨11,270
฿1,293.08
List Price:  ฿2,586.50
You save:  ฿1,293.41
₺1,646.44
List Price:  ₺3,293.30
You save:  ₺1,646.85
B$218.38
List Price:  B$436.81
You save:  B$218.43
R711.68
List Price:  R1,423.54
You save:  R711.85
Лв67.10
List Price:  Лв134.21
You save:  Лв67.11
₩55,741.82
List Price:  ₩111,497.59
You save:  ₩55,755.76
₪134.54
List Price:  ₪269.12
You save:  ₪134.57
₱2,284.41
List Price:  ₱4,569.39
You save:  ₱2,284.98
¥5,931.38
List Price:  ¥11,864.24
You save:  ¥5,932.86
MX$750.38
List Price:  MX$1,500.95
You save:  MX$750.57
QR145.58
List Price:  QR291.21
You save:  QR145.62
P536.90
List Price:  P1,073.94
You save:  P537.04
KSh5,166.70
List Price:  KSh10,334.70
You save:  KSh5,168
E£1,941.39
List Price:  E£3,883.26
You save:  E£1,941.87
ብር5,716.16
List Price:  ብር11,433.76
You save:  ብር5,717.59
Kz36,469.08
List Price:  Kz72,947.28
You save:  Kz36,478.20
CLP$38,726.71
List Price:  CLP$77,463.11
You save:  CLP$38,736.40
CN¥285.16
List Price:  CN¥570.39
You save:  CN¥285.23
RD$2,518.39
List Price:  RD$5,037.41
You save:  RD$2,519.02
DA5,195.45
List Price:  DA10,392.21
You save:  DA5,196.75
FJ$90.43
List Price:  FJ$180.89
You save:  FJ$90.46
Q306.32
List Price:  Q612.73
You save:  Q306.40
GY$8,355.08
List Price:  GY$16,712.25
You save:  GY$8,357.17
ISK kr4,932.76
List Price:  ISK kr9,866.76
You save:  ISK kr4,934
DH363.26
List Price:  DH726.63
You save:  DH363.36
L668.13
List Price:  L1,336.43
You save:  L668.29
ден2,110.62
List Price:  ден4,221.77
You save:  ден2,111.14
MOP$320.92
List Price:  MOP$641.92
You save:  MOP$321
N$704.48
List Price:  N$1,409.15
You save:  N$704.66
C$1,469.67
List Price:  C$2,939.71
You save:  C$1,470.03
रु5,632.07
List Price:  रु11,265.56
You save:  रु5,633.48
S/141.26
List Price:  S/282.56
You save:  S/141.30
K166.62
List Price:  K333.28
You save:  K166.66
SAR150.04
List Price:  SAR300.13
You save:  SAR150.08
ZK949.74
List Price:  ZK1,899.73
You save:  ZK949.98
L174.39
List Price:  L348.82
You save:  L174.43
Kč839.73
List Price:  Kč1,679.67
You save:  Kč839.94
Ft13,526.45
List Price:  Ft27,056.29
You save:  Ft13,529.83
SEK kr378.31
List Price:  SEK kr756.72
You save:  SEK kr378.41
ARS$54,428.90
List Price:  ARS$108,871.42
You save:  ARS$54,442.52
Bs275.96
List Price:  Bs551.99
You save:  Bs276.03
COP$160,141.69
List Price:  COP$320,323.44
You save:  COP$160,181.74
₡20,189.65
List Price:  ₡40,384.34
You save:  ₡20,194.69
L1,046.93
List Price:  L2,094.13
You save:  L1,047.20
₲288,443.91
List Price:  ₲576,959.95
You save:  ₲288,516.04
$U1,602.41
List Price:  $U3,205.22
You save:  $U1,602.81
zł146.11
List Price:  zł292.25
You save:  zł146.14
Already have an account? Log In

Transcript

Comparison operators are used when we want to compare two variables to one another. So for example, we have here two variables. The first one is a and the second one is B. And we want to compare which one is the bigger, I would just type A, and then greater than sign, and then B. And then I would just save and run our program. And I get in our count console.

True, because yes, a is four, which is greater than B, which is three. If I want to check which one is smaller, I would just add a smaller than sign as you can see, instead of the greater than, and I would just save and run our program. And it says here false, because A is greater than B and here it says a smaller than B. But there is a Also another way to check if a number is smaller than or equals. And in that case, we just add the equals sign besides the smaller than or greater than sign, and save our our program and run. And here it says false because A is greater than B, but here, it just checks if A is smaller than or equals b.

But let's change a from four to three. And if we save our program and run it again, we will get through because here it checks if A is smaller than or equals, and he has a equals b, which is true and hence it printed out true. And we could also check if a is greater than or equals b. And if I say from drawn, I am going to get to also because A equals B. But what if we want to check if A equals B just equals, I would just add three equals seven. And if I save and run, I get also true because A equals B, if I change a back to four, and I save again and run, I get false, because a does not equal to b.

And here it says A equals to B. If I want to change, if I want to check, if a does not equal to b, I would change the first I would replace the first equal sign with an exclamation mark and save and run. And I would get through because a does not equal to b and that is absolutely true. So comparison operators are very important when we want to compare two variables to one another. So to recap, we have greater than, we have smaller than, we have greater than or equals, we have smaller than or equal We have equals, we have does not equal

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.