Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Assignment is about a class which describes a jug of water. The jugs have an individual capacity (in litres) and water can be poured

PYTHON

Assignment is about a class which describes a jug of water. The jugs have an individual capacity (in litres) and water can be poured in and out. Water in the jug has a temperature which changes as additional water of a given temperature is poured in. For the purpose of this assignment it is assumed that the water's specific heat capacity and its density is temperature-independent. Further, it is assumed that the jug itself has negligible heat capacity and perfect insulation.

The assignment is to define a class Jug which exposes the following methods:

  • Jug creation: This takes a single parameter (aside from the standard self) which is the capacity (maximum volume of water it can accommodate) and creates an empty jug of that capacity.
  • Method pour_out(volume, into_jug=None): Water is poured out of the jug. volume is the volume in litres that is poured out. Alternatively, the string 'all' can be provided as volume, in which case the full volume of water currently in the jug is poured out. If the named parameter into_jug is assigned then the water is poured into the assigned jug. If into_jug isn't assigned, then the water is poured down the drain.
  • Method pour_in(volume, temperature): Water of the given volume and temperature is poured into the jug. Any excess water beyond the jug's capacity goes into the jug, mixes and causes water to overflow.
  • Method temperature(): Returns the temperature of the water in the jug.
  • Method water_volume(): Returns the volume of the water in the jug.
  • Method capacity(): Returns the capacity of the jug.

No other methods or attributes are exposed. Thus, if you define methods or variables to help you implement the class Jug, then their names should start with an underscore.

Assume that the water mixes and achieves a homogeneous temperature without delay. If you pour water into a jug without it overflowing, then the resulting temperature is calculated as expected from the details given at the top.

If the jug is full and added water causes it to overflow, then the temperature of water in the jug is derived as follows. When you pour water of temperature

in

in into a full jug with water temperature

, as an infinitesimal volume dV

dV is added

changes to

+d=capacity+

in

dV

in

capacity+dV

in

.

+d=(capacity+indVin)/(capacity+dVin).

Integrating this equation will yield the final temperature(V

in

)

(Vin)after a volumeV

in

Vinwith temperature

in

inhas been poured into a full jug, continuously mixing with the water in the jug and overflowing. Please derive (V

in

)

(Vin) analytically and use the resulting expression in your pour_in() method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago