0
Explain if statements please
I don't understand if statements
2 Respuestas
+ 3
If -else statements are used to enforce a condition.
For example you can understand this this way.
if the rain rains. Bring an Umbrella. Else. Leave it at home.
So that's how if else statements actually work.
Do when we go to the programming side it will look like this.
x = 5
y = 6
if x==y:
print("are the same")
else:
print("not the same")
The if statement will check if the variable x is the same as variable y.if they are the same then it will print the same.
If they are not the same now it will print not the same to the console
0
Thanks