30 Days of Python (19 Part Series)
If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.
False are the only possibilities with a boolean. However, you can use them for yes/no questions and many other things too.
is_dog = False is_coding = True is_programmer = True is_cat = False is_human = true # this is true, but will error because it isn't capitalized
False are constants with the values 1 & 0
True == 1 False == 0
Operators are the constructs which can manipulate the value of operands. -reference
+ - * / % // ** # math or arithmetic operators == != < > <> >= <= # comparison operators and or not # logical operators
I gave a bunch of examples in the post below.
you can compare numbers, words, lists, and more
|Operator||What it is||Example|
|!=||does not equal||
|>=||greater than or equal to||
|<=||less than or equal to||
not are useful for making decisions
dog_needs_exercise = True is_awake = True if dog_needs_exercise and is_awake: print("Take dog for a walk")
dog_hungry = False is_dinner_time = True if dog_hungry or is_dinner_time: print("Feed dog")
# getting paid this week? a = "go to work" b = "get work done" if a and b: print("You get paid") # because you did both if a or b: print("You won't get paid") # because you didn't do both
Series based on