0
Can you please explain else statement
Baby gaara (avatar) and I don't understand else statement please explain(what a else statement is)
46 Antworten
+ 9
The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed, which is the else statement.
For Example:
if (10 > 20) {
return "true"
} else {
return "false"
}
since 10 is not greater than 20, the code output will return "false". Hope that helped you.
+ 6
IF (my answer helped you)✅ run this {recognize my answer as the best for your understanding by choosing It}
ELSE ❎{recognize my effort in explain to you by upvoting It}
⚫️IF...STATEMENT fluxogram:
✅True, something happen, as turn left;
❌False, nothing happen.
⚫️IF...ELSE STATEMENT fluxogram:
✅True, something happen, like turn left;
❎False, the opposite thing happen, like turn right.
Code controling the flow of actions:
IF...ELSE STATEMENT case:
(Test is made)
⬇️
{Run IF is true}⬅️➡️ {ELSE run IF is false}
God bless us with love, peace and health! Hugs 🤜🏼🤛🏼.
+ 5
Hello there , well imagine with me for an instinct you went to do your day to day grocery shopping and you wanted to buy a specific product but there was none left of it! So you quickly thought and decided to buy an alternative one you found ! The same concept with code, the else statement is your a.k.a "alternative" , So when your program is executed it checks the condition of your if statement, If it was verified it runs the whole code nested within it! (if the product you wanted was available, you buy it)
Else : the "alternative" code runs
(there was no more left of the product, so you bought the alternative one! )
I hope it makes sense to you!
+ 5
Ritu Miah IF you are a Gaara.baby admirer(true), this will execute> {interpreting the Gaara.baby very wellly done hahahahahah(obs: he also wants to play with his parents and had socialization problems, and loneless)}
IF THE PREVIOUS TRUE STATEMENT IS FALSE and you do not admire baby Gaara, run this code > {Forgive me for misunderstand your intentions and feelings}
The second part, the IF THE PREVIOUS TRUE STATEMENT IS FALSE, can be simplified for ELSE, wich means an opposite situation from what It is expected.
The IF...STATEMENTS and IF...ELSE STATEMENTS are used for control the code flow, It produces a bifurcation in the street of code. If something is true, the left street is taken, in the IF STATEMENT case. If something is true, the left street is taken, or If something is false, the right street is taken, in the IF...ELSE STATEMENT case.
The IF...STATEMENTS set a verification and IF is true something happen, and IF the statement is false, nothing happen. The IF...ELSE STATEMENTS complement that notion...
+ 4
One explanation for baby Gaara and one explanation for Ritu Miah , all fine, all good hahaha.
+ 3
If you wanna talk follow each other than message each other because I didn't make this question so people could chat to one another
+ 3
I think u r not trying to understand if u try then all the comment on your question are enough..
😡😡😡
+ 3
In programming languages, an else statement is an alternative statement that is executed if the result of a previous test condition evaluates to false.
+ 2
So I spend time doing python
+ 2
Also what please don't say something bad
+ 2
Here when the condition in if was correct then it will display the statement otherwise else condition statement will display
+ 2
If statement works in true cinditions and else works in false conditions.
+ 2
An else statement cannot exist alone alright!.. imagine if you have to write a code block and ....
You have an aim that this particular code block should be executed only when a condition is satisfied..
However , you also have in mind what to do when the condition fails: there comes the else condition
See it will be like...
If ( condition)
{
Execute this block when condition true
}
else
{
Execute this block when condition is false
}
+ 2
Else statement runs only if the 'if' statement runs false. Else statements don't need any condition, it does the opposite of 'if' statement.
Also, you can give an elif statement which needs a condition, which runs if the 'if' statement runs false (a kinda else statement with conditions!).
+ 1
~ swim ~ No but just answering thinking completely beginner..
Because why he/she only asking else part only..
You can see in the description of adding childish info.. So.
Edit:
In between, when I started answer, I don't see your reply,. After I posted, after refreshing I see you already answered.. It happening most of times for same..
May be my typing skills very slow..
+ 1
Hello
+ 1
Are you gone
+ 1
????????????
+ 1
I am probably not supposed to understand this
+ 1
You may find answer in https://www.google.com/search?q=else+statement+in+JUMP_LINK__&&__python__&&__JUMP_LINK&rlz=1C9BKJA_enUS705US705&oq=else+statement+&aqs=chrome.1.69i57j0l3.10909j0j4&hl=en-US&sourceid=chrome-mobile&ie=UTF-8, https://www.tutorialspoint.com/python/python_if_else.htm..
You may see Python Library for details in https://docs.python.org/2/tutorial/controlflow.html.