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. Common data types include integers, floating-point numbers, strings, booleans, and arrays, each with its own set of permitted operations.

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

Showing a random 20 of 50 problems.

Example 1

easy
What data type is the value 42?

Example 2

easy
Classify each: (a) 100, (b) 'OK', (c) 2.5, (d) true, (e) [1,2].

Example 3

medium
What is 10%310 \% 3 (the modulo/remainder operation)?

Example 4

challenge
A program reads ['3','1','2'] (strings) and sorts them; then reads [3,1,2] (ints) and sorts. Both sort fine here, but when would string vs int sorting differ? Give the order for ['10','9','2'].

Example 5

easy
What data type is the value 'hello'?

Example 6

hard
A shop tracks prices as integer cents to avoid floating-point error. A bag of apples costs $3.45\$3.45. Store it as what integer, and what is the total cents for 44 bags?

Example 7

challenge
Sorting strings ['9','10','100','2'] lexicographically vs numerically gives different orders. Show both sorted lists.

Example 8

medium
Adding integer 44 and float 1.51.5 gives what type and value?

Example 9

easy
What data type is the value 3.14?

Example 10

easy
Which operation joins 'cat' + 'fish' into 'catfish'?

Example 11

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.

Example 12

challenge
A function expects an integer count but receives the float 4.0. It uses count as a list size. Why might this error, and what is the safe fix?

Example 13

medium
Adding an integer 5 and a float 2.5 gives what type and value?

Example 14

medium
Why does comparing 0.1 + 0.2 == 0.3 sometimes return false in floating-point?

Example 15

easy
Which operation joins two strings: addition (concatenation) or subtraction?

Example 16

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 17

medium
Zero-based index 2 of 'PYTHON' returns which character?

Example 18

medium
What is the result of '3' + '4' when both are strings?

Example 19

hard
In integer division, what is โˆ’7//2-7 // 2 if the language rounds toward negative infinity?

Example 20

easy
Are '5' (a string) and 5 (an integer) the same data type? Yes or no.