What does this code signify in relation to boolean logic?

  • Context: Python 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Code Logic Relation
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 1K views
shivajikobardan
Messages
637
Reaction score
54
Code:
my_age = 10

if my_age >= 100:
  print("One hundred years old! Very impressive.")
elif my_age <= 3:
  print("Awwww. Just a baby.")
else:
  print("Ah - a very fine age indeed")

https://www.fullstackpython.com/blog/python-basic-data-types-booleans.html
Article says-:
Booleans are used in your code to make it behave differently based on current conditions within your program. You can use boolean values and comparisons in conjunction with the if, elif, and else keyoards as one means to achieve this.
 
Physics news on Phys.org
It means that the keywords if and elif are followed by expressions (my_age >= 100 and my_age <= 3) that evaluate to boolean values (when my_age is 10 they both evaluate to False).

This is IMHO not a very good explanation of boolean logic in Python, it is more about conditional statements.
 
Reply
  • Like
Likes   Reactions: sysprog
exactly i felt the same it is so tough to figure out good explanations tbh