Expresiones Condicionales
# Stock level of an item stock_level = 15 # Simple `if`/`else` to check stock levels if stock_level < 20: print("Stock is low") else: print("Stock is okay")
# Initial conditions totalCost = 150 # Applying discounts based on purchase amount if totalCost >= 200: print("20% discount applied") elif totalCost >= 100: print("10% discount applied") else: print("No discount for purchases under $100")
# Initial conditions product = 'Non-Perishable' stock = 70 # Determine the handling of products based on type and condition if product == 'Perishable': if daysDelivered >= 4: print("Not fresh - Initiate discount") else: print("Product is fresh") elif product == 'Non-Perishable': if stock > 100: print("Consider discount") else: print("No discount needed") else: print("The product is not specified")
Tarea
Swipe to start coding
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!