Python Trung cấp cho Tài chính
Kennedy Behrman
Data Engineer, Author, Founder
trns = { 'symbol': 'TSLA', 'type':'BUY', 'amount': 300}
print(trns['amount'])
300
câu lệnh điều khiển
câu lệnh 1
câu lệnh 2
câu lệnh 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("Tìm thấy x trong y")
else:
print("Không có x trong y")
if x == y:
print("bằng")
elif x < y:
print("nhỏ hơn")
if x == y:
print("bằng")
elif x < y:
print("nhỏ hơn")
elif x > y:
print("lớn hơn")
elif x == 0
print("bằng 0")
if x == y:
print("bằng")
elif x < y:
print("nhỏ hơn")
elif x > y:
print("lớn hơn")
elif x == 0
print("bằng 0")
else:
print("Không thuộc các trường hợp trên")
Python Trung cấp cho Tài chính