Grokking Claude for Beginners
0% completed
Claude Code: A First Look
The function below comes from the checkout service that Maya's team owns. It is in the file discounts.py, and it applies a discount code to the total of an order.
def apply_discount(total, code): rate = DISCOUNTS.get(code, 0) total = total - total * rate return total - total * rate
What does an order of 40.00 dollars cost with the code WELCOME10, which is a discount of 10 percent?
The rate is 0.10. The third line subtracts 10 percent of 40.00, and the result is 36.00, which is the correct price. The fourth line then subtracts 10 percent of 36
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%