Week 2 — Basic Types, Operators & Modules
Interactive demos for Week 2 labs — numeric types, arithmetic expressions, division/modulo, strings, slicing, formatting, and more. Select a lab below.
Lab 2.20 — SSN Digit Extraction
How to use % (modulo) and // (integer division) to pull apart a 9-digit Social Security Number into its Area, Group, and Serial components.
Lab 2.24 — Midfix of 3
How to use len(), // (floor division), and string slicing to extract the middle 3 characters from a string.
Lab 2.25 — Pizza Party Planner
How to use math.ceil(), math.pi, and arithmetic to calculate how many pizzas to order and the amount of sauce needed.
Lab 2.27 — Contact List Lookup
How to use find(), len(), and string slicing to search a contact list and extract the matching phone number.