Conditional Logic
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
is_old = True
is_licensed = True
print("When is_old is True and is_licensed is True:")
if is_old:
print("You are old enough to drive")
elif is_licensed:
print("You can drive now")
else:
print("You are too young.")
print("\nWhen is_old is False and is_licensed is True:")
is_old = False
is_licensed = True
if is_old:
print("You are old enough to drive")
elif is_licensed:
print("You can drive now")
else:
print("You are too young.")
print("\nWhen is_old is True and is_licensed is True:")
is_old= True
is_licensed=True
if is_old and is_licensed:
print("You are old enough to drive, and you have a license")
else:
print("You are too young.")
print("\nWhen is_old is True and is_licensed is False:")
is_old= True
is_licensed=False
if is_old and is_licensed:
print("You are old enough to drive, and you have a license")
else:
print("You are too young.")
print("\nWhen is_old is False and is_licensed is True:")
is_old= False
is_licensed=True
if is_old and is_licensed:
print("You are old enough to drive, and you have a license")
elif is_old or is_licensed:
print("You have a license but you are not old enough")
else:
print("You are too young.")
Python
INFO