Decisions with Boolean operations
Boolean operations are used in Python to make decisions. Imagine that you work as an analyst identifying accounts that might potentially participate in stock trades. You might use this information to advise qualifying clients on market moves.
The variable is_investment_account
is supplied. It is set to True
if the given account includes stock positions as part of it's holdings. The supplied variable balance_positive
is set to True
if the account has a positive cash balance, which could be used to purchase securities.
This exercise is part of the course
Intermediate Python for Finance
Exercise instructions
- Print the value of the variable
balance_positive
. - Set the variable
potential_trade
toTrue
if the account is an investment account with a positive balance. - Print the
True
if this is a potential trade.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Print the given variables
print(is_investment_account)
print(____)
# Decide if this account is cantidate for trading advice
potential_trade = is_investment_account ____ balance_positive
# Print if this represents a potential trade
print(____)