-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtutorial_18.py
More file actions
34 lines (25 loc) · 821 Bytes
/
tutorial_18.py
File metadata and controls
34 lines (25 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
jake_age = 15
anne_age = 17
# are they the same age?
same_age = jake_age == anne_age
# are they different ages?
diff_age = jake_age != anne_age
# is jake younger / anne older
jake_younger = jake_age < anne_age
# is jake older / anne younger
anne_younger = jake_age > anne_age
# can also check greater than or equal, and less than or equal
print( jake_age <= 15 )
print( jake_age < 15 )
# notice the order doesn't matter as long as the logic is correct
print( 17 >= anne_age )
print( 17 > anne_age )
# compare lists, tuples, strings
print( 'a' < 'd' )
print( 'z' < 'd' )
print( 'cat' > 'cop' )
# compares: 80 > 80 or 70 > 65
print( [80,70,90] > [80,65] )
# compares: 'hello' == 'Hello' and 'there' == 'there'
# if the lengths don't match it will always be false.
print( ('hello', 'there') == ('Hello', 'there') )