Primitive Data

lecture
python
primitive-data-types
type-conversion

See csse1001 for course logistics — this note covers Lecture 2B’s technical content.

Today’s outline

  • Primitive data types built into Python
  • Booleans, integers, strings, and tuples
  • Converting between types

Learning objectives

  1. There are more built-in types besides integers that can form expressions.
  2. These types are immutable.
  3. We can convert between types, albeit imperfectly.

Primitive data

The types “built-in” to Python by default are called primitive data: booleans, integers, floats (not covered in this lecture), strings, and tuples.

See python-primitive-data-types for the full definitions, operators, and worked examples for each of these types — comparison operators and truthy/falsy values for booleans; unbounded-precision and conversion for integers; concatenation, comparison, indexing/slicing, and immutability for strings; and construction, indexing/slicing, immutability, and packing/unpacking for tuples.

Summary

We have booleans, integers, strings, and tuples. Strings and tuples are indexed and can be sliced. We can convert between the types (imperfectly).

Next lecture

  1. 2025-08-11-functions — Functions.
  2. 2025-08-11-sequence-selection-and-iteration — If-statements (selection).