I know that dogs += 5 means dogs = dogs + 5.** Initially, you gave the variable dogs a value of 15 . So when you add 5 , the new stored value is 20 . So now dogs = 20 .
I thought that as the program ran down the if-statements, that if would run the one that would be true. The only If-statement that I thought was true was if people == dogs since people was initialized as 20 and the new value for dogs is also 20. So shouldn’t “People are dogs.” only print?
Please clarify my misconception. What am I not understanding clearly?
HERE IS THE CODE
people = 20
cats = 30
dogs = 15
if people < cats:
print("Too many cats! The world is doomed!")
if people > cats:
print("Not many cats! The world is saved!")
if people < dogs:
print("The world is drooled on!")
if people > dogs:
print("The world is dry!")
dogs += 5
if people >= dogs:
print("People are greater than or equal to dogs.")
if people <= dogs:
print("People are less than or equl to dogs.")
if people == dogs:
print("People are dogs.")
HERE IS MY OUTPUT FROM TERMINAL
Too many cats! The world is doomed!
The world is dry!
People are greater than or equal to dogs.
People are less than or equl to dogs.
People are dogs.