What is the current state of water?
★☆☆In physics, a state of matter is one of the distinct forms in which matter can exist. Four states of matter are observable in everyday life: solid, liquid, gas, and plasma. Many intermediate states are known to exist, such as liquid crystal, and some states only exist under extreme conditions, such as Bose–Einstein condensates (in extreme cold), neutron-degenerate matter (in extreme density), and quark–gluon plasma (at extremely high energy).
Write a program that outputs liquid state, solid state or gaseous state depending on the temperature of water in °C.
Remember to add a comment before a subprogram or selection statement to explain its purpose.
water_state so that it:Enter the temperature in °C: 20
The water is in a liquid state.
Enter the temperature in °C: -8
The water is in a solid state.
Enter the temperature in °C: 106.89
The water is in a gaseous state.
# States of water problem
# -------------------------
# Subprograms
# -------------------------
# Return the state of water
---
def water_state(centigrade):
---
# Less than or equal to 0°
---
if centigrade <= 0:
---
return "solid"
---
# Less than 100° but greater than 0°
---
elif centigrade < 100:
---
return "liquid"
---
# 100° or above.
---
else:
---
return "gaseous"
---
# -------------------------
# Main program
# -------------------------
---
temperature = float(input("Enter the temperature in °C: "))
---
state = water_state(temperature)
---
print("The water is in a", state, "state.")