add another condition, while C1<-40, print("I cannot answer that")
时间: 2024-04-16 16:28:11 浏览: 13
Certainly! I have added the additional condition to check if the input value is less than -40. If it is, it will print the message "I cannot answer that". Here's the updated code:
```python
print("Suppose you have an American friend who doesn't know the difference between Celsius and Fahrenheit.")
print("You have to do the simple calculation for him.")
print("Tell me what is the weather now in Celsius. I will let you know the Fahrenheit number.")
print("Enter 'q' to quit")
while True:
C1 = input(">> ")
if C1 == 'q':
print("Byebye.")
break
try:
C1 = int(C1)
if C1 < -40:
print("I cannot answer that.")
elif C1 > 40:
print("Sorry, the number is out of scope.")
else:
F = int(9/5*C1+32)
print(F, "Fahrenheit")
except ValueError:
print("Please input a valid number.")
```
Now, if the input value is less than -40, it will display the message "I cannot answer that". The code also includes the previous condition to check if the input value is greater than 40 and displays the appropriate error message.
Let me know if you have any further questions or concerns!