ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Output/Printing numbers
J277 · 2.2.1

Unit 1 · Lesson 2

Printing numbers

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Distinguish numeric values from strings and print both correctly.

Numbers do not need quotation marks. 42 is an integer, but "42" is a string made of two characters. Both can be displayed, but the computer stores and uses them differently.

Integer

A whole number with no decimal point, such as 5, -20 or 0.

Real

A number that can have a decimal part, such as 3.5.

Literal

A value written directly into the code.

Keep these in mind

  • Whole numbers are integers.
  • A number inside quotes is a string.
  • Negative and decimal values can also be printed.

Learning objective

Distinguish numeric values from strings and print both correctly.

Exam tip

Keep the data type in mind: 123 and "123" may look alike in output, but one is an integer and one is a string.

Common mistake

Adding quotation marks turns a number into text. That matters later when the program needs to calculate with it.

PreviousNext