+ 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.

28th Jan 2021, 12:21 AM
Austin Lepari
Austin Lepari - avatar
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: ...
28th Jan 2021, 1:43 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
It's <= not =<
28th Jan 2021, 12:57 AM
Ă‡Ä«Ă±ĂŠĂžĂ»Ć“đŸ‘œ
Ă‡Ä«Ă±ĂŠĂžĂ»Ć“đŸ‘œ - avatar
+ 2
You type the bad way <=
28th Jan 2021, 12:36 AM
HBhZ_C
HBhZ_C - avatar
+ 2
28th Jan 2021, 1:26 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 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.
29th Jan 2021, 8:13 PM
StephBill
StephBill - avatar
+ 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.
28th Jan 2021, 11:37 AM
Adamyan
Adamyan - avatar
+ 1
temp is string 100 is integer, we can't take two various data types ...
29th Jan 2021, 9:23 PM
oswaldy
oswaldy - avatar
0
<= not =< int<=string will give error
28th Jan 2021, 12:23 PM
Nurmuhammet Tajimyradow
Nurmuhammet Tajimyradow - avatar
0
6th Sep 2022, 4:03 AM
21CSE8401 ABDUL HAKKEEM M.
21CSE8401 ABDUL HAKKEEM M. - avatar
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
8th Sep 2022, 3:55 AM
Nirmal kumar S
Nirmal kumar S - avatar