Chapter 3 Exercise Set 2: PCEP Practice¶
The ==
operator¶
Evaluate each of the following expressions:
42 == 42
42 == 42.
42 == 43
Other comparision operators¶
Evaluate each of the following expressions:
42 != 42
42 > 42.
42 < 43
Updated Precedence Table¶
Priority |
Operator |
|
---|---|---|
1 |
+, - |
unary |
2 |
** |
|
3 |
*, /, //, % |
|
4 |
+, - |
binary |
5 |
<, <=, >, >= |
|
6 |
==, != |
Challenge: Greater than?¶
Using one of the comparison operators in Python, write a simple two-line
program that takes the parameter n as input, which is an integer, and prints
False
if n is less than 42, and True
if n is greater than or equal to
42.