主要指標の計算
フードデリバリープラットフォームの開発者として、ビジネスの重要な指標を計算する場面があります。recent_orders は、ピーク時の直近1時間における注文金額のリストです。
指標を手動で計算することもできますが、Python の組み込み関数を使うと、より効率的かつ迅速に処理できます。
この演習はコースの一部です
開発者向け中級 Python
演習の手順
- 最小注文金額を求め、
smallest_orderに保存しましょう。 - 最大注文金額を求め、
largest_orderに保存しましょう。 - 合計売上を計算し、
total_revenueに保存しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
recent_orders = [15.99, 28.50, 42.75, 18.99, 55.00, 31.25, 22.99, 67.50]
# Find the smallest order amount
smallest_order = ____(recent_orders)
# Find the largest order amount
largest_order = ____(recent_orders)
# Calculate total revenue from all orders
total_revenue = ____(recent_orders)
print("Smallest order:", smallest_order)
print("Largest order:", largest_order)
print("Total revenue:", total_revenue)