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.42
List Price:  €68.85
You save:  €34.42
£29.88
List Price:  £59.76
You save:  £29.88
CA$56.19
List Price:  CA$112.40
You save:  CA$56.20
A$61.63
List Price:  A$123.28
You save:  A$61.65
S$51.88
List Price:  S$103.77
You save:  S$51.89
HK$310.77
List Price:  HK$621.63
You save:  HK$310.85
CHF 31.77
List Price:  CHF 63.55
You save:  CHF 31.78
NOK kr402.08
List Price:  NOK kr804.27
You save:  NOK kr402.18
DKK kr257.08
List Price:  DKK kr514.23
You save:  DKK kr257.15
NZ$69.95
List Price:  NZ$139.92
You save:  NZ$69.97
د.إ146.87
List Price:  د.إ293.79
You save:  د.إ146.91
৳4,875.14
List Price:  ৳9,751.50
You save:  ৳4,876.36
₹3,518.11
List Price:  ₹7,037.11
You save:  ₹3,518.99
RM169.11
List Price:  RM338.27
You save:  RM169.16
₦58,698.12
List Price:  ₦117,410.92
You save:  ₦58,712.80
₨11,316.02
List Price:  ₨22,634.87
You save:  ₨11,318.85
฿1,310
List Price:  ฿2,620.34
You save:  ฿1,310.33
₺1,678.29
List Price:  ₺3,357
You save:  ₺1,678.71
B$215.25
List Price:  B$430.57
You save:  B$215.31
R692.26
List Price:  R1,384.70
You save:  R692.44
Лв67.28
List Price:  Лв134.58
You save:  Лв67.30
₩57,232.85
List Price:  ₩114,480.02
You save:  ₩57,247.16
₪131.60
List Price:  ₪263.23
You save:  ₪131.63
₱2,330.99
List Price:  ₱4,662.57
You save:  ₱2,331.57
¥6,075.56
List Price:  ¥12,152.65
You save:  ¥6,077.08
MX$736.51
List Price:  MX$1,473.21
You save:  MX$736.69
QR145.64
List Price:  QR291.33
You save:  QR145.68
P569.34
List Price:  P1,138.84
You save:  P569.49
KSh5,166.70
List Price:  KSh10,334.70
You save:  KSh5,168
E£1,902.40
List Price:  E£3,805.28
You save:  E£1,902.88
ብር5,998.45
List Price:  ብር11,998.40
You save:  ብር5,999.95
Kz36,470
List Price:  Kz72,949.12
You save:  Kz36,479.12
CLP$38,085.71
List Price:  CLP$76,180.95
You save:  CLP$38,095.23
CN¥284.71
List Price:  CN¥569.49
You save:  CN¥284.78
RD$2,535.99
List Price:  RD$5,072.61
You save:  RD$2,536.62
DA5,216.73
List Price:  DA10,434.77
You save:  DA5,218.04
FJ$91.81
List Price:  FJ$183.65
You save:  FJ$91.83
Q306.31
List Price:  Q612.71
You save:  Q306.39
GY$8,366.98
List Price:  GY$16,736.05
You save:  GY$8,369.07
ISK kr4,873.98
List Price:  ISK kr9,749.18
You save:  ISK kr4,875.20
DH367.66
List Price:  DH735.41
You save:  DH367.75
L679.06
List Price:  L1,358.30
You save:  L679.23
ден2,122.40
List Price:  ден4,245.33
You save:  ден2,122.93
MOP$320.23
List Price:  MOP$640.55
You save:  MOP$320.31
N$693.41
List Price:  N$1,386.99
You save:  N$693.58
C$1,471.67
List Price:  C$2,943.71
You save:  C$1,472.04
रु5,622.90
List Price:  रु11,247.21
You save:  रु5,624.31
S/135.05
List Price:  S/270.14
You save:  S/135.08
K170.61
List Price:  K341.26
You save:  K170.65
SAR149.97
List Price:  SAR299.99
You save:  SAR150.01
ZK904.84
List Price:  ZK1,809.92
You save:  ZK905.07
L174.98
List Price:  L350.01
You save:  L175.02
Kč837.08
List Price:  Kč1,674.37
You save:  Kč837.29
Ft13,400.07
List Price:  Ft26,803.51
You save:  Ft13,403.43
SEK kr376.44
List Price:  SEK kr752.98
You save:  SEK kr376.54
ARS$58,276.64
List Price:  ARS$116,567.85
You save:  ARS$58,291.21
Bs276.32
List Price:  Bs552.72
You save:  Bs276.39
COP$153,682.17
List Price:  COP$307,402.78
You save:  COP$153,720.60
₡20,101.91
List Price:  ₡40,208.85
You save:  ₡20,106.93
L1,050.87
List Price:  L2,102.01
You save:  L1,051.13
₲283,298.74
List Price:  ₲566,668.34
You save:  ₲283,369.59
$U1,595.06
List Price:  $U3,190.53
You save:  $U1,595.46
zł145.87
List Price:  zł291.77
You save:  zł145.90
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.