FOR WHAT PURPOSE WE USE BOOLEAN??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

FOR WHAT PURPOSE WE USE BOOLEAN???

?????????????????????

6th Mar 2018, 2:32 PM
Jayesh Sharma
Jayesh Sharma - avatar
9 Answers
+ 5
Boolean is used in condition testing
6th Mar 2018, 3:46 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 3
Do you know it? - false Did you write in caps and wrote a lot of '?'? - true
6th Mar 2018, 2:40 PM
D B
D B - avatar
+ 3
Basicly it is answering/asking "Yes/No"-Questions
6th Mar 2018, 2:48 PM
D B
D B - avatar
+ 3
Boolean gives only 2 results - True or False Right or wrong Yes or Not
6th Mar 2018, 2:51 PM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
+ 3
to keep it simple, a boolean is an on off switch. Maybe your making Mario Bros. You can't jump if you aren't on the ground. You push the A button... if(onGround==True) Jump if(onGround==False) No Jump Your writing a simple while loop. Use a boolean to tell it when to stop. run=True while run==True: loop until run=False
6th Mar 2018, 3:43 PM
LordHill
LordHill - avatar
+ 2
ok thns
6th Mar 2018, 3:08 PM
Jayesh Sharma
Jayesh Sharma - avatar
+ 1
This avoids you to use useless conditions. For example : //without boolean function test() { return 0 } if(test()==0){ //code here } //with boolean function test() { return true } if(test()) { //don't have to check an equality //code here } and if you want to check if the function returns false you can just write : if(!test()) But this can also help you if the function has to return a number resulting of a calculation. If there is an invalid parameter, you can just return false to prevent of the error.
6th Mar 2018, 3:20 PM
Αητοιπe
Αητοιπe - avatar
+ 1
@D B I don't understand sorry
6th Mar 2018, 6:13 PM
Αητοιπe
Αητοιπe - avatar
0
@Antoine Bergerault: In your last sentence: I want a number! What is... ? Function: "False" Do. Not. Return. Other. Datatypes. If anybody thinks different, let me know.
6th Mar 2018, 3:42 PM
D B
D B - avatar