Computer Science
Ask the user to enter a temperature in Celsius. The program should print a message based on the temperature:
- 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.
Answer
temp = float(input("Enter Temperature in Celsius: "))
if temp < -273.15 :
print("Temperature is invalid as it is below absolute zero")
elif temp == -273.15 :
print("Temperature is absolute zero")
elif -273.15 <= temp < 0:
print("Temperature is below freezing")
elif temp == 0 :
print("Temperature is at the freezing point")
elif 0 < temp < 100:
print("Temperature is in the normal range")
elif temp == 100 :
print("Temperature is at the boiling point")
else :
print("Temperature is above the boiling point")
Output
Enter Temperature in Celsius: -273.15
Temperature is absolute zero
Related Questions
Write a program using nested loops to produce a rectangle of *'s with 6 rows and 20 *'s per row.
Write a program to display all of the integers from 1 up to and including some integer entered by the user followed by a list of each number's prime factors. Numbers greater than 1 that only have a single prime factor will be marked as prime.
For example, if the user enters 10 then the output of the program should be:
Enter the maximum value to display: 10
1 = 1
2 = 2 (prime)
3 = 3 (prime)
4 = 2x2
5 = 5 (prime)
6 = 2x3
7 = 7 (prime)
8 = 2x2x2
9 = 3x3
10 = 2x5Given three numbers A, B and C, write a program to write their values in an ascending order. For example, if A = 12, B = 10, and C = 15, your program should print out:
Smallest number = 10
Next higher number = 12
Highest number = 15Write a Python script to input temperature. Then ask them what units, Celsius or Fahrenheit, the temperature is in. Your program should convert the temperature to the other unit. The conversions are:
F = 9/5C + 32 and C = 5/9 (F 32).