- 2
What the difference between :
= and == , <= and < and what is the means of while
3 ответов
+ 1
=for setting value and the other signs are used for comparing.
The operators are used to compare with one value to another if the condition becomes true it returns true otherwise false.
== means if it's equal or not
>=means greater than or equal
> means greater than
< means less than
<= means less than or equal
!= means not equal
while is a loop that is used to execute an amount of code for a certain time until the condition inside while loops are true.Read the comments of the lesson the comments are very useful.Also please next time include the language tag.
0
Hi, Ranjana Sharma!
In Python, = is used when assigning a value to a variable:
variable = 3
== is used to compare to values:
if variable1 == 3:
print("Variable1 is equal to 3")
< means smaller than:
3<5 -- True 3<3 -- False
<= means smaller or equal to:
3<=4 -- True 3<=3 -- True
while loop repeats an action if a condition is true, this code for example, will add 1 to variable until variable is equal or bigger than 5:
while variable < 5:
variable = variable + 1
I hope that was useful, Ranjana Sharma.
0
Thanku so much