ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Data types & casting/Strings and integers
J277 · 2.2.2

Unit 4 · Lesson 1

Strings and integers

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Distinguish strings from integers and choose a suitable type in context.

A data type tells the computer what a value means. 123 is an integer that can be used in calculations. "123" is a string containing three characters. Real values can have decimals, Boolean values have exactly two states, and a character is one symbol. Choose the type from the value's purpose, not just how it looks.

Data type

A classification that controls what data can be stored and which operations can be used.

String

A sequence of characters used for names, text, identifiers and phone numbers.

Integer

A whole number with no decimal point.

Real

A numeric value that can include a decimal part.

Boolean

A value with exactly two possible states: true or false.

Character

A single letter, digit, symbol or space.

Keep these in mind

  • Quotation marks create a string.
  • Integers are whole numbers, including zero and negatives.
  • Real values can include a decimal part.
  • Use Boolean only when there are exactly two states.
  • Phone numbers are strings because leading zeroes and + symbols matter.

Learning objective

Distinguish strings from integers and choose a suitable type in context.

Exam tip

Justify a type in context. A phone number should be a string because it is not used for arithmetic and may begin with 0.

Common mistake

A value containing digits is not automatically an integer. IDs, postcodes and phone numbers are usually strings.

PreviousNext