Question
22.4 Lab week 3: Exercise 4 Write a python program that do the following: (1) Prompt the user to input an item description (string), a
22.4 Lab week 3: Exercise 4
Write a python program that do the following: (1) Prompt the user to input an item description (string), a number of items (integer) and the price of one item (floating-point). (Submit for 3 points)
Enter the description: Spiral Notebook Enter the number of items: 1500 Enter the price of one item: 7.2
(2) Update to output a string that says "items 'description' at $price is $total"; where items is the number of items, description (surrounded by apostrophies) is the item description, price is the price of one item, and total is the price of buying these items. Both price and total are displayed with commas and two decimal places; and items with commas when appropriate. (Submit for 6 points, so 9 points total)
Enter the description: Spiral Notebook Enter the number of items: 1500 Enter the price of one item: 7.2 1,500 'Spiral Notebook' at $7.20 is $10,800.00
Your program will be test with the following values:
description | items | price | Output |
---|---|---|---|
"Spiral Notebook" | 1500 | 7.2 | "1,500 'Spiral Notebook' at $7.20 is $10,800.00" |
"Panasonic ErgoFit Earbud" | 2 | 9.17 | "2 'Panasonic ErgoFit Earbud' at $9.17 is $18.35" |
"Lamborghini Huracan" | 1 | 199800 | "1 'Lamborghini Huracan' at $199,800.00 is $199,800.00" |
This is my current code:
description = input('Enter the description: ') number = int(input('Enter the number of items: ')) price = float(input('Enter the price of one item: ')) print('{:,} {} at ${:.2f} is ${:,.2f}'.format(number,description,price, price*number))
How do you put in apostrophes on Python? I need to get apostrophes around the description value. Ex. 'Spiral Notebook'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started