0
Can someone explain booleans?
im completily new
6 Réponses
+ 2
it's like int and str, but contains only two values: true or false.
human = true
marcian = false
print("human")
OUTPUT:
true
0
human = true
marcian = false
print("human")
OUTPUT:
true
-----------------------------
1) output is human, as " " are used in the print function. To print a variable no " " need to be used. In this case just print(human). And the output will be True.
2) True and False must start with capital letters otherwise you will get an error: true/false not declared.
Anyway booleans are often used to determine if a statement is true or false. Further on it can be used when user is logging in to system for example. To see if password is correct or not. :) and so on...
- 1
thank you so much, got it now :))
- 1
boolean like binary has only two values..true and false while binary has one and two
- 1
Binary has 0 and 1.