Practice Data Types in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

Categories that classify data values and determine which operations can validly be performed on them.

Different kinds of data (numbers, text, true/false) work differently.

Example 1

easy
Classify each value into its data type: (a) 42, (b) 'Hello', (c) 3.14, (d) TRUE.

Example 2

medium
A program reads user input as a string '25'. What happens if you try to calculate '25' + 10 without type conversion? What should you do instead?

Example 3

medium
For each scenario, choose the most appropriate data type: (a) a student's name, (b) number of students in a class, (c) whether a student passed, (d) a student's average grade (e.g., 87.5).

Example 4

hard
A program stores prices as integers in pence (e.g., 499 for ยฃ4.99) rather than as floats. Explain two advantages of this approach.