Intermediate Python for Finance
Kennedy Behrman
Data Engineer, Author, Founder
==
,!=
<
,>
,<=
,>=
Test equality: ==
Assign value: =
13 == 13
True
count = 13
print(count)
13
date_close_high = datetime(2019, 11, 27)
date_intra_high = datetime(2019, 11, 27)
print(date_close_high == date_intra_high)
True
d1 = {'high':56.88, 'low':33.22, 'closing':56.88}
d2 = {'high':56.88, 'low':33.22, 'closing':56.88}
print(d1 == d2)
True
d1 = {'high':56.88, 'low':33.22, 'closing':56.88}
d2 = {'high':56.88, 'low':33.22, 'closing':12.89}
print(d1 == d2)
False
print(3 == 3.0)
True
print(3 == '3')
False
print(3 != 4)
True
print(3 != 3)
False
<
<=
>
>=
print(3 < 4)
True
print(3 < 3.6)
True
print('a' < 'b')
True
date_close_high = datetime(2019, 11, 27)
date_intra_high = datetime(2019, 11, 27)
print(date_close_high < date_intra_high)
False
print(1 <= 4)
True
print(1.0 <= 1)
True
print('e' <= 'a')
False
print(6 > 5)
print(4 > 4)
True
False
print(6 >= 5)
print(4 >= 4)
True
True
print(3.45454 < 90)
True
print('a' < 23)
<hr />----------------------------------------------
TypeError Traceback (most recent call last)
...
TypeError: '<' not supported between instances of 'str' and 'int'
Intermediate Python for Finance