Data Type

In AP Computer Science Principles, a data type is the classification of a value (number, Boolean, string, or list) that determines what operations make sense on it, per EK AAP-1.A.3. The variable is the container; the data type describes what kind of thing is inside.

Verified for the 2027 AP Computer Science Principles examLast updated June 2026

What is Data Type?

A data type is a category for values in a program. The CED (EK AAP-1.A.3) names the four you need for AP CSP: numbers, Booleans, strings, and lists. The type tells you two things at once. First, what the value actually is (the number 42 versus the string "42" versus the Boolean true). Second, what operations are legal on it. You can divide two numbers, but dividing two strings is meaningless. You can ask for the length of a string or a list, but not of a Boolean.

Here's the mental model that makes it click. A variable is a labeled box that holds one value at a time (EK AAP-1.A.1). The data type describes what kind of thing is in the box. When you write gpa ← 3.85, the variable is gpa and its value's type is a number (specifically a decimal, which many languages call a float). One twist worth knowing: the AP pseudocode on the exam reference sheet doesn't make you declare types the way Java does. You just assign values, and the type comes along for the ride. But you still have to reason about types constantly, because choosing the wrong one (or treating one type like another) is exactly the kind of error MCQs love to test.

Why Data Type matters in AP Computer Science Principles

Data types live in Unit 3: Algorithms and Programming, Topic 3.1 (Variables and Assignments), supporting learning objectives AP Comp Sci P 3.1.A (represent a value with a variable) and AP Comp Sci P 3.1.B (determine the value of a variable after assignment). You can't represent a value well without picking a sensible type for it. Storing a GPA as a string, or a date of birth as three loose integers, technically works but creates real problems for processing the data later. Types also set up everything that follows in Unit 3. String operations, Boolean expressions in conditionals, and list procedures all depend on you recognizing what type you're working with. And in the Create Performance Task, your written responses are easier when you can name the types your program uses (a list of strings, a Boolean flag, a numeric counter).

How Data Type connects across the course

Variables and Assignments (Unit 3)

A variable holds one value at a time, and that value has a type. When you trace a ← 1, b ← a, a ← 2, you're tracking both the value and the kind of value each variable holds. Type and variable are inseparable on trace questions.

String (Unit 3)

Strings are the data type for text. The classic trap is a number disguised as a string. "3.85" looks like a GPA, but as a string you can't do math on it. Recognizing string versus number is one of the most tested type distinctions.

Integer and Float (Unit 3)

Both are numbers, but integers are whole values (a count of students) and floats carry decimals (a GPA of 3.85). Picking integer versus float is the practical version of 'choose the right data type' that practice questions ask about.

len() function (Unit 3)

Operations are type-specific, and len() proves it. Asking for the length of a string or a list makes sense; asking for the length of the number 42 does not. If you know a value's type, you know which built-in procedures can touch it.

Is Data Type on the AP Computer Science Principles exam?

Data types show up in multiple-choice questions in a few predictable shapes. One asks you to pick the most appropriate type for a scenario, like storing a student's GPA (a decimal number, not a string or integer). Another flips it and asks which value would be stored least efficiently or sensibly as a given type. A third tests design judgment, like why three separate integer variables for year, month, and day are worse than one specialized date representation (you lose validation and easy comparison). You'll also see conceptual-error questions where a value is represented with the wrong kind of variable. The FRQ side of AP CSP is the Create Task written response, where you describe the data your program stores. Being able to say 'this variable holds a list of strings' precisely is exactly what the rubric rewards. No released exam question requires you to recite a definition of data type; every question makes you apply it.

Data Type vs Variable

A variable is the named container; a data type is the kind of value inside it. score is a variable. The 95 it holds is a number, and that's its data type. They get confused because in AP pseudocode you never write the type out loud. You just assign a value, so the type hides inside the value. When a question asks about the variable, think name and storage. When it asks about the type, think what kind of thing the value is and what operations work on it.

Key things to remember about Data Type

  • A data type classifies a value as a number, Boolean, string, or list, which are the four types named in EK AAP-1.A.3.

  • The data type determines which operations are legal, so you can do arithmetic on numbers but not on strings, and you can take the length of strings and lists but not of Booleans.

  • AP pseudocode does not require type declarations; you just assign values with ←, and the type travels with the value.

  • The number 42 and the string "42" look alike but behave completely differently, and the exam tests whether you can tell them apart.

  • Choosing the right type is a design decision the exam tests directly, like using a float for a GPA instead of an integer or a string.

  • A variable is the container and the data type describes what kind of value the container holds.

Frequently asked questions about Data Type

What is a data type in AP Computer Science Principles?

A data type is the classification of a value that determines what operations can be performed on it. The AP CSP CED (EK AAP-1.A.3) names four: numbers, Booleans, strings, and lists.

Do you have to declare data types in AP CSP pseudocode?

No. Unlike Java or C, the AP exam reference language just uses assignment (a ← expression) with no type declarations. The value you assign carries its type implicitly, but you still have to reason about types to answer questions correctly.

What's the difference between a variable and a data type?

A variable is a named container that holds one value at a time (EK AAP-1.A.1), while the data type describes what kind of value is inside it. In gpa ← 3.85, the variable is gpa and the data type of its value is a number.

Is the number 42 the same as the string "42"?

No, and this distinction shows up on the exam. The number 42 supports arithmetic like 42 + 1 = 43, while the string "42" supports text operations like len("42") = 2. Treating one like the other is a classic conceptual error MCQs test.

What data type should you use for a GPA?

A decimal number (often called a float), because a GPA like 3.85 needs a fractional part and needs to support math like averaging. An integer would lose the decimal, and a string would block arithmetic entirely. This exact scenario appears in practice questions.