Python 3.13.6 (tags/v3.13.6:4e66535, Aug 6 2025, 14:36:00) [MSC v.1944 64 bit (AMD64)] on win32 Enter "help" below or click "Help" above for more information. i = 10 i 10 if i < 20: print('hi') print('ho') hi ho if i >30: print('hey') if i < 18: print('may not vote') may not vote score = 75 if score >= 90: grade = 'A' elif score >= 80: grade = 'B' elif score >= 70: grade = 'C' elif score >= 60: grade = 'D' else: grade = 'F' print(f"Grade: {grade}") Grade: C score = 65 if score >= 90: grade = 'A' else: if score >= 80: grade = 'B' else: if score >= 70: grade = 'C' else: if score >= 60: grade = 'D' else: grade = 'F' print(f"Grade: {grade}") Grade: D grade_map = { "A": 4.000, "A-": 3.667, "B+": 3.333, "B": 3.000, "B-": 2.667, "C+": 2.333, "C": 2.000, "C-": 1.667, "D+": 1.333, "D": 1.000, "D-": 0.667, "F": 0.000, } grade_map {'A': 4.0, 'A-': 3.667, 'B+': 3.333, 'B': 3.0, 'B-': 2.667, 'C+': 2.333, 'C': 2.0, 'C-': 1.667, 'D+': 1.333, 'D': 1.0, 'D-': 0.667, 'F': 0.0} grade_map.get('A-', "Invalid Grade") 3.667 grade_map['A-') SyntaxError: closing parenthesis ')' does not match opening parenthesis '[' grade_map['A-'] 3.667 grade_map['E'] Traceback (most recent call last): File "", line 1, in grade_map['E'] KeyError: 'E' grade_map.get('E', "Invalid Grade") 'Invalid Grade' (3+7) if 7 <= 3 else 2 2 (3+7) if 7 > 3 else 2 10 j = (3+7) if 7 > 3 else 2 j 10 "hello world" if True else "Eat ice cream" 'hello world' "hello world" if False else "Eat ice cream" 'Eat ice cream' mood = 'good' "hello world" if mood=='good' else "Eat ice cream" 'hello world' message = "hello world" if mood=='good' else "Eat ice cream" message 'hello world' mood = 'bad' action = "hello world" if mood=='good' else "Eat ice cream" f"To do: {action}" 'To do: Eat ice cream' 10 - 5 - 4 1 "-: left associative: left - will be executed first" '-: left associative: left - will be executed first' 10 – (5 – 4) SyntaxError: invalid character '–' (U+2013) 10 – (5 – 4) SyntaxError: invalid character '–' (U+2013) 10 - (5-4) 9 10 – 3 * 2 SyntaxError: invalid character '–' (U+2013) >>> 10 - 3*2 4 >>> '* has a higher precedence than -: it will be executed first' '* has a higher precedence than -: it will be executed first' >>> 2 ** 3 8 >>> 2 * 3 ** 2 18 >>> ' ** has a higher precedence than *' ' ** has a higher precedence than *' >>> 2 ** 3 ** 2 512 >>> '** is right associative: right ** will be executed first." SyntaxError: unterminated string literal (detected at line 1) >>> '** is right associative: right ** will be executed first.' '** is right associative: right ** will be executed first.' >>> 1 < 2 or 3 < 4 and 4 > 6 True >>> True or True and False True >>> (True or True) and False False >>> True or (True and False) True >>> 'and has a higher precedence than or' 'and has a higher precedence than or' >>> l1 = [1,2,1,2,3] >>> l1[3] 2