Comparing sales and purchases
If statements let you branch your code to take different actions depending on the state of your data. Imagine you are working at a small firm trying to keep the number items sold in balance with those purchased. You are supplied with two lists, purchases
, which contains items purchased, and sales
, which contains items sold. Use if
statements to compare the two lists.
Este exercício faz parte do curso
Intermediate Python for Finance
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Get number of purchases
num_purchases = len(purchases)
# Get number of sales
num_sales = ____(sales)
# Check if more sales than purchases
____ num_purchases < num_sales:
print('buy more')