Page 1 of 1

Python: "If" as Truth Teller

Posted: Fri May 22, 2026 7:45 pm
by Jason

Code: Select all

print(f"Jerry is 1 year of age.")

is_Jerry_old = bool(False)

if is_Jerry_old:

print(f"Jerry is old.")

else

print(f"Jerry is not old.")

# Will print out "Jerry is not old." with no parentheses.

print(f"Larry is a cat. ")

is_larry_a_cat = bool(No)

if is_larry_a_cat:

print(f"Larry is a cat.")

else:

print(f"Larry is not a cat.")

# The code will print out "Larry is a cat." 
# but Larry being a cat is unknown. 
#The problem is that without a 
#specific true or 
#false, the code will only test
# if the variable has a
 #value, known as True, or does not, 
 # known as False.