DS 1501 · Lesson 2 of 24
Instructor: Corey Schafer11m
Sign in to watchMaster the core building blocks of Python expressions: printing output, documenting intent with comments, binding variables, and predicting exact operator precedence. What you will learn: • Output with print(), escape characters (\n, \t), and single-line comments (#). • Variable naming rules (snake_case, cannot start with a digit or use reserved keywords). • Arithmetic operators: + - * / (true float division), // (floor division), % (modulo), ** (right-associative exponentiation). • Relational and logical operators: == != < <= > >= and, or, not. • Precedence hierarchy: () -> ** -> unary +/- -> * / // % -> + - -> comparisons -> not -> and -> or. University Outline Mapping: Class 2 · CO1 · Reading: 2.1–2.5 (Deitel) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 02 | CO1 | Reading: Deitel 2.1–2.5 Classic Midterm Precedence Traps: 2 ** 3 ** 2 -> 512 (right-associative: 2 ** (3 ** 2)) -3 ** 2 -> -9 (** binds tighter than unary -: -(3 ** 2)) -7 // 3 -> -3 (floor division rounds toward -infinity) 10 / 2 -> 5.0 (/ always produces float) not False and True or False -> True Practice: Trace operator outputs step-by-step in Python Tutor and attempt Lab Quiz 1 & 4 on CSECommunity.
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community