0

Could someone explain Booleans?

It didn't really explain it all that well :(

13th Jun 2017, 12:51 PM
saifelden Ismail
saifelden Ismail - avatar
2 ответов
+ 3
Boolean is a binary variable with two possible values true(1) or false(0).
13th Jun 2017, 1:29 PM
Lord Krishna
Lord Krishna - avatar
+ 2
Boolean variables are simply a switch. it is either on or off. If you have a game with a locked door. trying to open it could check a boolean variable. hasKey = True .... Door Opens hasKey = False ... Door doesn't open If you have a while loop, you generally have a boolean variable to run and stop it. running=True; while(running==True){ //Do something until running==False } I made TicTacToe the other day. I used booleans for each square to check if it was available for a move choice. Also used one to track if the game had a winner. If winner=True I don't allow any more moves until you hit reset. There are endless uses for boolean variables
13th Jun 2017, 1:43 PM
LordHill
LordHill - avatar