Explain if statements please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Explain if statements please

I don't understand if statements

4th Nov 2021, 5:54 PM
Ayesha Ahmed
Ayesha Ahmed - avatar
2 Answers
+ 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
4th Nov 2021, 6:08 PM
MATOVU CALEB
MATOVU CALEB - avatar
0
Thanks
4th Nov 2021, 11:05 PM
Ayesha Ahmed
Ayesha Ahmed - avatar