in python2.2Write a program that prompts the user for two inputs: the unit cost of an item and the quantity of the item. The program should then output the subtotal for the item in currency format with two decimals and the $ sign right up against the first digit. This will require the sep argument. See page 66 and the Sample Output. NOTE: User inputs are shown in blue.Sample OutputEnter the unit price 2.49Enter the quantity 8Please pay $19.92

Question
Asked Oct 5, 2019
49 views

in python

2.2Write a program that prompts the user for two inputs: the unit cost of an item and the quantity of the item. The program should then output the subtotal for the item in currency format with two decimals and the $ sign right up against the first digit. This will require the sep argument. See page 66 and the Sample Output. NOTE: User inputs are shown in blue.
Sample Output
Enter the unit price 2.49
Enter the quantity 8
Please pay $19.92

check_circle

Expert Answer

Step 1

round() function is used to round the number.

Syntax of round function:

round(number [, ndigit])

number is first argument of round of where number that is to rounded.

ndigit is second argument used for number of precision point.

 

sep argument is used to separate two values on the basis of “ ”, “_”, “-” etc.

Step 2

Program code:

unitcost=float(input("Enter the unit price: "))

quantity=int(input("Enter the quantity: "))...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: please help me solve this problem in C++

A: Program AlgorithmDeclare the required variables and an array.Then write a for loop to generate three...

question_answer

Q: Write a program that contains 2 methods, main and printLine 1) The printLine method will do the foll...

A: Program plan: Import necessary packages.Define a class named “PrintCheck”.Define a method called “pr...

question_answer

Q: Hello good afternoon,   Use functional decomposition to write a C++ program that asks the user to en...

A: create three methods with void return type as well as declare input variables as a global variable, ...

question_answer

Q: Draw the truth tables for the following Boolean expressions. xy+yz+xz x¯y+yz¯+x¯z (x⊕y)+(y⊕z)+(x...

A: Hello. Since you have posted multiple questions and not specified which question needs to be solved,...

question_answer

Q: how hard is computer programming and what level of math do I need to be successful.

A: Difficulties in computer programming:Computer programming is defined as the process of writing instr...

question_answer

Q: Beacon frames in the frequency hopping spread spectrum variant of 802.11 contain the dwell time. Do ...

A: NO,  as we know the Bluetooth frame has dwell time of 625p sec for basic data rate in the frame its ...

question_answer

Q: If you are not able to specify the output of the above program exactly, explain why.

A: The sample output of the given program is:

question_answer

Q: Using Java Eclipse do the following program: Design a class named Rectangle to represent a rectangle...

A: Program Instructions:Declare variables width and height.Create a default and parameterized construct...

question_answer

Q: ASSIGNMENTWrite a Java program that meets these requirements.• Create a NetBeans project named Lastn...

A: Here we create an XML file that contains:<?xml version="1.0" encoding="utf-8" ?><quiz>&l...