BestPromptFinder
HomeCoding › 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

Source

Hugging Face

Related Coding prompts

PRD to MVP Technical Plan
Quality 93 · Claude Code
Full-Stack CRUD App Builder
Quality 93 · Claude Code
Legacy Refactor Planner
Quality 93 · Claude Code
Test Suite Generator
Quality 93 · Claude Code
Third-Party API Integration
Quality 93 · Claude Code
Database Schema and Migration
Quality 93 · Claude Code