Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 2 - Elementary Programming - Programming Exercises - Page 56: 2.8

Answer

Step 3 of 3 Sample Output: Enter the amount of water in kilograms: $55.5$ Enter the initial temperature: $3.5$ Enter the final temperature: $10.5$ The energy needed is $1625484.0$

Work Step by Step

Step 1 of 3 Program Plan: Create a python file with name 2_8PE.PY. In the file, - Get input from user. It is the weight of water in kilograms. - Also prompt the user for initial and final temperature of water individually. - Calculate energy required to heat water from the given initial to final temperature. - Display the energy required to heat water from the given initial to final temperature. Step 2 of 3 Program: # Prompt the user for water in kilograms mass $=$ eval(input ( "Enter the amount of water in kilograms: ")) # Prompt the user for initial temperature initialTemp = eval(input( "Enter the initial temperature: ")) # Prompt the user for final temperature finalTemp = eval(input("Enter the final temperature: ")) # Calculate energy required to heat water from initial #to final temperature energy $=$ mass $^{*}(\text { finalTemp }-\text { initialTemp })^{*} 4184$ #Display the energy required print("The energy needed is ", energy) Step 3 of 3 Sample Output: Enter the amount of water in kilograms: $55.5$ Enter the initial temperature: $3.5$ Enter the final temperature: $10.5$ The energy needed is $1625484.0$
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.