Question

Below is the Unit conversion knowledge base: 1 gallon = 4 quarts (= 128 oz) 1...

Below is the Unit conversion knowledge base:
1 gallon = 4 quarts (= 128 oz)
1 quart = 4 cups (= 32 oz)
1 cup = 8 ounces (oz)
1 liter = 33.814 ounces
write any program to take liter as input, then print out the corresponding amount of gallons, the remaining should then be display in quarts, cups, and ounces correspondingly.

Example:
input: 7 liters
output: "7 liters is equivalent to 1 gallon(s) 3 quart(s) 1 cup(s) and 4.698 oz"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

liters=int(input("Enter liters:"))
ounces=liters*33.814
#Here we convert liters into ounces(oz)
gallons=ounces/128
#Here we find the no of gallons l gallon =128 ounces
ounces=ounces % 128
#Here we find the remining ounces
quarts=ounces/32
#Here we find the no of quarts 1 quart = 32 ounces
ounces=ounces%32
#Here we find the remining ounces
cups=ounces/8
#Here we find the no of cups 1 cup = 8 ounces
ounces=ounces%8
#Here we find the remining ounces(oz)
print(liters,"liters is equivalent to ",int(gallons),"gallon(s)",int(quarts),"quart(s)",int(cups),"cup(s) and {:.3f} oz".format(ounces))
#Here we print the final result

Output:

Enter liters:7 7 liters is equivalent to 1 gallon (s) 3 quart(s) 1 cup (s) and 4.698 oz

indentation:

liters=int (input (Enter liters:)) ounces=liters*33.814 #Here we convert liters into ounces (oz) gallons=ounces/128 #Here w


answered by: ANURANJAN SARSAM
Add a comment
Answer #2

Code:

liters=int(input("Enter liters:"))
ounces=liters*33.814
#Here we convert liters into ounces(oz)
gallons=ounces/128
#Here we find the no of gallons l gallon =128 ounces
ounces=ounces % 128
#Here we find the remining ounces
quarts=ounces/32
#Here we find the no of quarts 1 quart = 32 ounces
ounces=ounces%32
#Here we find the remining ounces
cups=ounces/8
#Here we find the no of cups 1 cup = 8 ounces
ounces=ounces%8
#Here we find the remining ounces(oz)
print(liters,"liters is equivalent to ",int(gallons),"gallon(s)",int(quarts),"quart(s)",int(cups),"cup(s) and {:.3f} oz".format(ounces))
#Here we print the final result

Output:

Enter liters:7 7 liters is equivalent to 1 gallon (s) 3 quart(s) 1 cup (s) and 4.698 oz

indentation:

liters=int (input (Enter liters:)) ounces=liters*33.814 #Here we convert liters into ounces (oz) gallons=ounces/128 #Here w

Add a comment
Know the answer?
Add Answer to:
Below is the Unit conversion knowledge base: 1 gallon = 4 quarts (= 128 oz) 1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer the following questions using the next chart Recipe Detail and Cost Card Selling Price: Item Portion Cost: Maritime Clam Chowder Menu Dinner Portion 8 oz Quantity Unit Food Cost 96: 25%...

    Answer the following questions using the next chart Recipe Detail and Cost Card Selling Price: Item Portion Cost: Maritime Clam Chowder Menu Dinner Portion 8 oz Quantity Unit Food Cost 96: 25% Yield Date 2017-01-16 6 portions Cost Calculation $4.21 Ext Ingredients Butter $4.99 $1.70 $2.79 $5.13 $2.99 30g 350g kg Salt Pork, Diced Onion, diced 120 Celery, diced 2.5kg 51g 200ml 500ml Flour Clam Stock $1.68 Milk 2% 300mlL sprig 25 springs $2.50 1 sprig 25 springs$2.50 Parsley Chopped...

  • Below are some potentially useful conversion 1 lb 1 gallon l quart = - 453.6 4...

    Below are some potentially useful conversion 1 lb 1 gallon l quart = - 453.6 4 quartts 0.946 L The can be used to find the concentration of hydroxide ions, and thus determine the pH given a concentration of of aluminum. At what pH will precipitation of Al(OH), begin if 5.10 lb of aluminum sulfate, Al(SO4), is added to 1950 gallons of water with a negligible change in volume)? Express your answer numerically to two decimal places. View Available Hint(s)...

  • • Determine the correct answer lui . Be sure you are comfortable performing these sorts of...

    • Determine the correct answer lui . Be sure you are comfortable performing these sorts of calculation Unit Conversions: 1 fluid Ounce = 29.6 milliliters (ml) 1 cup = 8 fluid Ounces (oz) = 240 ml • 1 pint = 2 cups = quart • 1 gallon = 3.8 liters (L) • 1 ounce (mass) = 1/16 pound (lb) = 28 grams (6) 1 pound = 0.454 kilograms (kg) Nutrient-kcal Relationships • Fat: 9 kcal/g Carbohydrate: 4 kcal/g Protein: 4...

  • can you plzzz explain in detail Econ 113 Practice Final Multiple Choice Questions Use the following question 1: to...

    can you plzzz explain in detail Econ 113 Practice Final Multiple Choice Questions Use the following question 1: to answer Figure 5.1 Fishing charters 4 4- 2 1- ac- BC 12345 678910 Parachute jumps 1. (Figure 5.1) Francis spends his income on fishing charters and jumping out of airplanes. Which of the following statements is TRUE? Fishing charters are an inferior good. A B) An increase in income could cause the optimal consumption bundle to move from point A to...

  • The place values for the eight binary digits used in IPv4 addressing are as follows: 128,...

    The place values for the eight binary digits used in IPv4 addressing are as follows: 128, 64, 32, 16, 8, 4, 2, 1. Expand this range to include an additional four bits. Do this by recording the place values for 211, 210, 29, and 28. 1111 Express the decimal value 2001 in binary by placing 1s in the binary positions requiring the addition of the corresponding place value. Place 0s in the binary positions where the corresponding place value should...

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not receive any credit, so be sure that your code interprets correctly...

  • Lab 4: Java Fundamentals, Part IV In this assignment, you solve a conversion problem similar to...

    Lab 4: Java Fundamentals, Part IV In this assignment, you solve a conversion problem similar to Programming Challenge 1 of Chapter 3 of your text, page 184 (187 in Edition 5). Given one of the Roman numerals I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, XIII, XIV, XV as an input your program must determine and display the corresponding decimal digit 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15....

  • All information about the question (Task 1 and task 2) are down below Programming Assignments Task...

    All information about the question (Task 1 and task 2) are down below Programming Assignments Task 1 – Page 39. in Programming A Comprehensive Introduction Update your program from Assignment 2, Task #2 Allow the user to input their weight for the earth weight to moon weight conversion problem. Add an ifstatement that prompts the user if she inputs 0 or a negative number for her earth weight. #13. Mars’ gravity is about 17 percent less that of the earth’s....

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. DON'T use Function concept or any other concept except while loop,if-else. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not...

  • Assignment Overview This programming assignment is intended to demonstrate your knowledge of the following:  Writing...

    Assignment Overview This programming assignment is intended to demonstrate your knowledge of the following:  Writing a while loop  Writing a for loop  Writing a while loop with a sentinel value Chocolate Coupons Foothill Fro-cho, LLC, gives customers a coupon every time they purchase a chocolate bar. After they earn a certain number of coupons, they qualify for a free chocolate bar, which they may use toward the purchase of a single chocolate bar. Usually, 7 is the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT