Home ›
Coding › Below is an instruction that describes a task. Write a respo...
Below is an instruction that describes a task. Write a respo...
Coding · General · Coding
62Quality
90%Useful
87Reliability
The prompt
Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Write a Python program to calculate the total cost of a shopping cart. The program should consider the item prices, quantity, shipping cost, and any applicable taxes. ### Input: [ {"name": "widget", "price": 10, "quantity": 5 }, {"name": "thingy", "price": 7, "quantity": 3 }, {"name": "doodad", "price": 5, "quantity": 2 }, ] Shipping cost: 7.50 Tax rate: 9.5% ### Output: items = [ {"name": "widget", "price": 10, "quantity": 5 }, {"name": "thingy", "price": 7, "quantity": 3 }, {"name": "doodad", "price": 5, "quantity": 2 }, ] taxRate = 0.095 shippingCost = 7.50 totalCost = 0 for item in items: totalCost += item['price'] * item['quantity'] totalCost += totalCost * taxRate totalCost += shippingCost print('Total cost:', totalCost)
Find similar in the app →
Why this prompt
- AI-graded 62/100 for quality and structure
- 90% found it useful across General
Source
Hugging Face
Related Coding prompts
PRD to MVP Technical Plan
Quality 93 · Claude CodeFull-Stack CRUD App Builder
Quality 93 · Claude CodeLegacy Refactor Planner
Quality 93 · Claude CodeTest Suite Generator
Quality 93 · Claude CodeThird-Party API Integration
Quality 93 · Claude CodeDatabase Schema and Migration
Quality 93 · Claude Code