Negating with Boolean operators
It is often the case that you need to combine Boolean operations to solve more complicated problems. Let's say that you need to know if you need to download the closing stock prices for today. You only want to do the operation if the markets have already closed. The closing prices are a list held in the provided variable closing_prices
. The supplied variable market_closed
is set to True
once the markets close. Use Boolean operations and what you know about how objects evaluate in them to determine if you should download the data.
Este exercício faz parte do curso
Intermediate Python for Finance
Instruções do exercício
- Set the variable
not_prices
toTrue
if you do not have closing prices for today. - Set the variable
get_prices
toTrue
if the market is closed and you don't have closing prices yet.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
print(closing_prices)
# Assigning True if we need to get the prices
not_prices = ____ closing_prices
print(not_prices)
# Get prices if market is closed and we don't have prices
get_prices = ____ (market_closed ____ not_prices)
print(get_prices)