• If the temperature is less than -273.15, print that the temperature is invalid because it is
below absolute zero.
• If it is exactly -273.15, print that the temperature is absolute 0.
• If the temperature is between -273.15 and 0, print that the temperature is below freezing.
• If it is 0, print that the temperature is at the freezing point.
• If it is between 0 and 100, print that the temperature is in the normal range.
• If it is 100, print that the temperature is at the boiling point.
• If it is above 100, print that the temperature is above the boiling point
# Ask the user for a temperature in Celsius
temp_c = input("Enter a temperature in Celsius: ")
# Check if the input is a valid number
if temp_c.isdigit():
temp_c = float(temp_c)
# Print a message based on the temperature
if temp_c < -273.15:
print("Invalid temperature. Temperature is below absolute zero.")
elif temp_c == -273.15:
print("The temperature is absolute zero.")
elif temp_c < 0:
print("It's freezing!")
elif temp_c < 10:
print("It's cold.")
elif temp_c < 25:
print("It's comfortable.")
else:
print("It's hot.")
else:
print("Invalid temperature. Please enter a number.")
The output of the program would depend on what the user enters as input. Here are some example outputs:
Input: -300
Output: Invalid temperature. Temperature is below absolute zero.
Input: -273.15
Output: The temperature is absolute zero.
Input: -5
Output: It's freezing!
Input: 20
Output: It's comfortable.
Input: 30
Output: It's hot.
Input: abc
Output: Invalid temperature. Please enter a number.
0 Comments