Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

6.3 (2 of 2): Counted, measured, grouped, and coding words

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Can you score 2.5 goals?

You cannot score 2.5 goals. You score 2 or 3. But you can run 2.5 kilometres. And your team colour is not a number at all.

All three are data, but they are three different kinds. The kind decides what you can do with the data. This lesson also turns words into data a computer can count.

Key words

WordWhat it meansExample
Discrete valueA counted number that jumps between whole values.Goals: 0, 1, 2, 3
Continuous valueA measured number that can be any value in a range.Height: 1.723 metres
Categorical valueThe name of a group.Red, blue, green
CodifyTo turn words into a fixed set of codes a computer can count."The coach was late" becomes "transport"
Single objectData stored and read as one whole piece.A photo or a comment
Structured dataData in a fixed shape of rows and columns.A table
Qualitative dataData that describes in words, pictures or sound.A comment
Quantitative dataData that is a number.5 stars

The cells students fill in are left blank in this preview.

Which kind of value?

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Discrete: you count it

You count a discrete value. There is a gap between one value and the next.

Goals, students, cars, brothers and sisters. You can have 2 or 3. You cannot have 2.5.

Continuous: you measure it

You measure a continuous value. It can be any value, even between two others.

Height, weight, time, temperature. 1.7 metres, 1.72 metres, 1.723 metres. How exact it is depends on the tool you use.

Categorical: you group it

A categorical value is the name of a group. Colour, country, bus route, year group.

You can count how many are in each group. You cannot add "red" and "blue". Careful: a bus route such as 42 looks like a number, but it is only a name.

Quick check: which kind?

Have a go

Quick check: which kind?

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Three kinds of value

KindQuestionExampleCan use decimals?
DiscreteHow many?Goals scored: 3No
ContinuousHow much? How long?Journey time: 12.5 minutesYes
CategoricalWhich group?Bus route: 42No, it is a name

The cells students fill in are left blank in this preview.

Words are stored as one piece

A comment such as "The coach was late" is qualitative data. A computer stores it as a single object: one whole piece. You get the whole comment or nothing.

You cannot ask "how many comments are about transport?" You must read each one first.

Codify: turn words into groups

To count words, give each comment a group. This is to codify it.

"The coach was late" becomes the code "transport". "Lunch was small" becomes "food". Now the data is structured: a category in a column. You can count it, sort it and chart it.

Try it: codify one comment

Code: python
comment = "We waited a long time for the coach"
text = comment.lower()

if "coach" in text or "late" in text or "wait" in text:
    category = "transport"
# elif means: if the line above was not true, try this one.
elif "lunch" in text or "food" in text:
    category = "food"
else:
    category = "other"

print("Comment:", comment)
print("Code:", category)

# Change the comment to "Lunch was too small" and run it again.

Make a free account to save your work and track your progress.

From a comment to a count

Arrows go from "Comment: The coach was late" to "Which keyword is in it?", then to "transport" for coach, late, wait, to "food" for lunch, food, to "activity" for museum, castle, guide and to "other" for none, and from each group to "Count each group".Arrows go from "Comment: The coach was late" to "Which keyword is in it?", then to "transport" for coach, late, wait, to "food" for lunch, food, to "activity" for museum, castle, guide and to "other" for none, and from each group to "Count each group".

Your turn: codify the comments

A school trip survey has free text comments. Fill in two functions. The first turns one comment into one category: transport, food, activity or other. The second counts how many comments are in each category. Press Run Tests to check.

Code: python
def codify(comment):
    # Turn one comment into one category word. Ignore capital letters.
    # If it has "coach", "late" or "wait" in it, give back "transport".
    # Else if it has "lunch" or "food" in it, give back "food".
    # Else if it has "museum", "castle" or "guide" in it, give back "activity".
    # Otherwise give back "other".
    return None


def count_categories(comments):
    # Codify every comment. Give back a dictionary that counts each category,
    # for example {"transport": 2, "food": 1}. Only list categories that appear.
    return None

Make a free account to save your work, or press Start lab to work through the whole lesson.

Codifying loses something

Warning

Many people think a code keeps everything a comment says. It keeps only one idea. "The coach was late but the castle was great" has two ideas, so one code loses one of them. The detail and the feeling go too. So keep the original words as well, if you can.

Judge the choice

Have a go

Judge the choice

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Key words crossword

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Watch: counted, measured, grouped and coding words

Press Play on the short film below. It starts with three values, then shows the three kinds, a comment and its code, then one myth.

Film: counted, measured, grouped and coding words

Counted, measured, grouped, and coding words

Every scene, as text

  1. The kind decides what you can do. 2 or 3 students, never 2.5 (discrete: you count it). Run 2.5 kilometres (continuous: you measure it). Your team colour (categorical: you group it).
  2. Three kinds of value. Discrete: how many? (you count it: no decimals). Continuous: how much? How long? (you measure it: decimals, like 12.5 minutes). Categorical: which group? (you group it: no decimals, it is a name).
  3. Categorical: you group it. Red, blue, green (categorical: the name of a group). Bus route: 42 (still a name: it only looks like a number). You can count how many are in each group.
  4. Words are stored as one piece. "The coach was late" (qualitative data: it describes in words; single object: one whole piece). You get the whole comment or nothing. How many comments are about transport? (to answer: read each one first).
  5. Codify: turn words into groups. A table of Comment and Code: The coach was late, transport; Lunch was small, food (codify: words into a fixed set of codes; structured: a category in a column).
  6. Myth (false): a code keeps everything a comment says. The coach was late but the castle was great (two ideas: the coach and the castle). That is not true: a code keeps only one idea. transport (code: keeps the coach, loses the castle). Keep the original words as well, if you can.

Final check

Have a go

Final check

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Remember

Tip

Discrete: counted. Continuous: measured. Categorical: grouped. Words are stored as one object. Codify them into groups to make them structured.

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.