+ 2
Need help with "if statements"
I am doing a tutorial where I am creating an input for temp and if the input exceeds 100 degrees celsius I need the output to be "Boiling". the code I used was temp = int(input()) if temp =< "100": print("Boiling") the error Im getting is File "/usercode/file0.py", line 2 if temp =< "100": ^ SyntaxError: invalid syntax if I remove the equal sign it just moves to the < sign... please help.
11 Respostas
+ 5
In addition to =< being incorrect as stated, "100" is of type str (string) not int. Remove the quotes or convert to int().
if temp <= 100:
...
+ 4
It's <= not =<
+ 2
You type the bad way <=
+ 2
+ 2
Think of the "verbal" form: first greater/lesser than or equal to. Maybe this helps to remember. Plus, a integer (100) stands alone, if you put it in quotes, it becomes a string.
+ 1
It is ok in input, but in If statement must be temp <= 100, your code wrong, because Python dons't have =< comparison, and '100' must be int type.
+ 1
temp is string
100 is integer, we can't take two various data types ...
0
<= not =<
int<=string will give error
0
0
Write a program that checks if the water is boiling.
Take the integer temperature in Celsius as input and output "Boiling" if the temperature is above or equal to 100.
Sample Input
105
Sample Output
Boiling
temp = int(input())
# your code goes here
if temp>=100:
print("boiling")
elif temp==100:
print("boiling")
test 3 & test 4 not open
plese tell the answer