Master if/elif/else statements and conditional logic in Python.
1age = 182 3if age >= 18:4 print("You are eligible to vote.")5 print("Please register at your local office.")6 7print("Thank you!") # Always runsYou are eligible to vote. Please register at your local office. Thank you!
1score = 752 3if score >= 90:4 grade = "A"5elif score >= 80:6 grade = "B"7elif score >= 70:8 grade = "C"9elif score >= 60:10 grade = "D"11else:12 grade = "F"13 14print(f"Your grade: {grade}") # Your grade: CYour grade: C
1age = 252has_license = True3is_insured = False4 5# and — both must be True6if age >= 18 and has_license:7 print("You can drive.")8 9# or — at least one must be True10if has_license or is_insured:11 print("You have some coverage.")12 13# not — inverts the boolean14if not is_insured:15 print("Consider getting insurance.")You can drive. You have some coverage. Consider getting insurance.