In the lectures the professor says Booleans (and, or) are a type of data. Why aren't they considered operations?
Boolean is a primitive data type. Examples of Boolean data: True, False. Integer is also a primitive data type. Examples of Integer data: 1, 2, 3, ... You perform operations on data. Examples of Integer operators: +, -, Examples of Boolean operators: and, or, and not. Here is a very simple program that uses Boolean data and operators: a = False b = True print (a and b) print (a or b) print (not a)
Continuing on what the last person said, a boolean is a type because it is actually a variable that takes up a space in memory. It can be called, and dereferenced ect. However, booleans dont necessarily have to be declared either. If(a==b) is also an example of a boolean. If you were to actually print this program a = 0 b = 0 print(a==b) You would get a console response of True.
Now and or and not depends on which version of the operators you are using. Bitwise and/or will return 0 or 1 depending on the bit thats being compared to it. 10000101 11100001 and --------- 10000001 Now there are the abstract versions of and and or that will compare if either are true. If((a==1 and b==5) or c == 10) < again a comparison of boolean values. do code If(a is not 5) do other code ect ect
Join our real-time social learning platform and learn together with your friends!