Cart Total
In an online store, the final cart total depends on item prices, quantities, and a shared discount. Given a list items, where each item contains price and qty, and a discount percentage discount, calculate the total cost. Apply the discount and return the result rounded to two decimal places.
Примеры
Ввод
[[100, 2], [50, 1]], 0Вывод
250Ввод
[[100, 1]], 10Вывод
90Ввод
[], 50Вывод
0Нужно реализовать
def cart_total(items: list, discount: int) -> float:
Теги
dictmath
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięVisible tests
1
Input
[[100,2],[50,1]], 0Expected
2502
Input
[[100,1]], 10Expected
903
Input
[], 50Expected
04
Input
[[199,3]], 100Expected
05
Input
[[33,3]], 10Expected
89.16
Input
[[10,1],[20,2]], 25Expected
37.5Focus radio
Paused · SomaFM · Fluid