Practice Integer in CS Thinking
Use these practice problems to test your method after reviewing the concept explanation and worked examples.
Quick Recap
A data type that represents whole numbers (positive, negative, or zero) without decimal points. Integers are stored exactly in memory and support arithmetic operations like addition, subtraction, multiplication, and integer division.
Integers are counting numbers in code โ things you can count without fractions: age, score, quantity, index.
Showing a random 20 of 50 problems.
Example 1
easyWhat are the results of: (a) 25 MOD 7, (b) 100 DIV 3, (c) 8 MOD 2?
Example 2
mediumCompute `-7 % 2` in Python (result takes the sign of the divisor).
Example 3
hardFor arrays of length 7, what is the wrap-around index of in Python?
Example 4
mediumTrace: `n = 17`. Compute `n // 10` and `n % 10`. What are they?
Example 5
mediumA signed 8-bit integer ranges from to . How many distinct values does it represent?
Example 6
mediumTrace: . Compute and .
Example 7
mediumA program uses integers in cents to store dollars. \$3.47 is stored as what integer?
Example 8
easyCompute `5 * 4` (integer multiplication).
Example 9
mediumTrace: . Compute weeks and leftover days as and .
Example 10
mediumCompute the last digit of `1234` using modulo.
Example 11
mediumConvert 125 seconds to minutes and seconds using integer arithmetic.
Example 12
easyFill in: means is ___.
Example 13
mediumConvert 90 minutes to hours and minutes using `//` and `%` with 60.
Example 14
mediumA vending machine program stores the price as 175 (meaning \$1.75 in cents). A customer inserts 200 cents. Using only integer arithmetic (DIV for integer division, MOD for remainder), calculate the change in dollars and remaining cents.
Example 15
easyCompute (integer division).
Example 16
mediumUse modulo to wrap an index: with array length 5, what is index `7 % 5`?
Example 17
mediumCompute `-7 // 2` in Python (floor division rounds toward negative infinity).
Example 18
hardTrace a loop: ; while : print ; . What sequence is printed?
Example 19
easyTrue or false: is an integer.
Example 20
challengeHow many trailing zeros does have in base 10, computed using repeated ?