Data Types CS Thinking Example 1

Follow the full solution, then compare it with the other examples linked below.

Example 1

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

Solution

  1. 1
    Step 1: 42 is a whole number with no decimal point โ€” this is an integer.
  2. 2
    Step 2: 'Hello' is text enclosed in quotes โ€” this is a string.
  3. 3
    Step 3: 3.14 has a decimal part โ€” this is a float (real number). TRUE is a logical value โ€” this is a boolean.

Answer

(a) Integer, (b) String, (c) Float/Real, (d) Boolean.
Data types define what kind of value a variable holds and what operations can be performed on it. The four fundamental types are integer, float, string, and boolean.

About Data Types

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.

Learn more about Data Types โ†’

More Data Types Examples