Ask Question
26 July, 10:31

Write a Python program that requests the price and weight of an item in pounds and ounces, and then determines the price per ounce from the below inputEnter price of item: 25.50Enter weight of item inpounds and ounces separately. Enter pounds: 1Enter ounces: 9Price per ounce: $1.02

+3
Answers (1)
  1. 26 July, 13:44
    0
    The program to this question as follows:

    Program:

    price=float (input ('Enter total price: ')) #define variable price and take user-input

    print ('Enter value of weight separately into pounds and onces: ') #print message

    pounds=int (input ('Input pounds value: ')) # defining variable pounds and take user-input

    ounces=int (input ('Input ounces value: ')) # defining variable ounces and take user-input

    total_ounces=pounds*16+ounces # defining variable total_ounces and calculate variable

    total=price/total_ounces # defining variable total and calculate price/ounces

    print ('price/ounces is: ', total) #print value

    Output:

    Enter total price: 25.50

    Enter value of weight separately into pounds and onces:

    Input pounds value: 1

    Input ounces value: 9

    price/ounces is: 1.02

    Explanation:

    In the above python program code, a variable "price" is defined, that is takes price value from user, to take this value the "input and float" is used, in which the "float" convert value into decimal and input function is used for user - input.

    In the next line, the print function is declared, which is used for print message and variable values, in this function, we print a message that takes two values separately. Then two-variable "pounds and ounces" are defined that take integer value separately. In the last step, the total_ounces variable is defined, which calculates total ounces and the total variable will use to calculate the price per ounces. The print function is used to print this variable value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a Python program that requests the price and weight of an item in pounds and ounces, and then determines the price per ounce from the ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers