Intermediate Python for Finance
Kennedy Behrman
Data Engineer, Author, Founder
trns = { 'symbol': 'TSLA', 'type':'BUY', 'amount': 300}
print(trns['amount'])
300
control statement
statement 1
statement 2
statement 3
if <expression> :
if x < y:
if x in y:
if x and y:
if x:
if <expression>:
statement
statement
statement
if <expression>: statement;statement;statement
trns = { 'symbol': 'TSLA', 'type':'BUY', 'amount': 300}
if trns['type'] == 'SELL':
print(trns['amount'])
trns['type'] == 'SELL'
False
trns = { 'symbol': 'APPL', 'type':'SELL', 'amount': 200}
if trns['type'] == 'SELL':
print(trns['amount'])
200
if x in y:
print("I found x in y")
else:
print("No x in y")
if x == y:
print("equals")
elif x < y:
print("less")
if x == y:
print("equals")
elif x < y:
print("less")
elif x > y:
print("more")
elif x == 0
print("zero")
if x == y:
print("equals")
elif x < y:
print("less")
elif x > y:
print("more")
elif x == 0
print("zero")
else:
print("None of the above")
Intermediate Python for Finance