MulaiMulai sekarang secara gratis

Calculating key metrics

As a developer for a food delivery platform, you might need to calculate important metrics for your business. You have access to recent_orders, a list containing order amounts from the past hour during peak traffic.

While you can manually calculate metrics, Python's built-in functions provide efficient and faster solutions.

Latihan ini adalah bagian dari kursus

Intermediate Python for Developers

Lihat Kursus

Petunjuk latihan

  • Find the smallest order amount, saving as smallest_order.
  • Find the largest order amount, saving as largest_order.
  • Calculate the total revenue, saving as total_revenue.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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)
Edit dan Jalankan Kode