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
easyWhat data type is the value 42?
Example 2
easyClassify each: (a) 100, (b) 'OK', (c) 2.5, (d) true, (e) [1,2].
Example 3
mediumWhat is (the modulo/remainder operation)?
Example 4
challengeA 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
easyWhat data type is the value 'hello'?
Example 6
hardA shop tracks prices as integer cents to avoid floating-point error. A bag of apples costs . Store it as what integer, and what is the total cents for bags?
Example 7
challengeSorting strings ['9','10','100','2'] lexicographically vs numerically gives different orders. Show both sorted lists.
Example 8
mediumAdding integer and float gives what type and value?
Example 9
easyWhat data type is the value 3.14?
Example 10
easyWhich operation joins 'cat' + 'fish' into 'catfish'?
Example 11
hardA 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
challengeA 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
mediumAdding an integer 5 and a float 2.5 gives what type and value?
Example 14
mediumWhy does comparing 0.1 + 0.2 == 0.3 sometimes return false in floating-point?
Example 15
easyWhich operation joins two strings: addition (concatenation) or subtraction?
Example 16
mediumA 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
mediumZero-based index 2 of 'PYTHON' returns which character?
Example 18
mediumWhat is the result of '3' + '4' when both are strings?
Example 19
hardIn integer division, what is if the language rounds toward negative infinity?
Example 20
easyAre '5' (a string) and 5 (an integer) the same data type? Yes or no.