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.
Latihan ini merupakan bagian dari kursus
Intermediate Python for Finance
Latihan interaktif langsung praktik
Cobalah latihan ini dengan melengkapi kode contoh ini.
# 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')