🧠 Quick Study Guide: Data Types
- 🔢 Integers: Whole numbers (positive, negative, or zero) without any decimal points. Used for counting, ages, quantities.
Examples: 5, -100, 0, 12345.
- 📈 Floats (Floating-Point Numbers): Numbers that contain a decimal point. Used for measurements, prices, precise calculations.
Examples: 3.14, -0.5, 99.99, 2.0.
- 📝 Strings: Sequences of characters (letters, numbers, symbols) enclosed within single or double quotation marks. Used for text, names, messages.
Examples: "Hello World", 'Python', "123", "eokultv".
- ✅ Booleans: Represent logical truth values, either
True or False (or their numerical equivalents, 1 or 0). Used for conditional logic and flags.
Examples: True, False.
- 💡 Why Data Types Matter: They tell the computer how to interpret and store data, influencing what operations can be performed and how much memory is used.
🤔 Practice Quiz
- 1. Which of the following is an example of an Integer?
- A) "42"
- B) 42.0
- C) 42
- D) True
- 2. Identify the Floating-Point number among the options:
- A) -15
- B) "3.14"
- C) 0.001
- D) False
- 3. What data type is "eokultv rocks!"?
- A) Integer
- B) Float
- C) String
- D) Boolean
- 4. Which of these represents a Boolean value?
- A) 100
- B) "False"
- C)
False
- D) 0.5
- 5. If you try to add the string "5" to the integer 3, what is the most likely outcome in many programming languages?
- A) The result will be 8.
- B) The string "53" will be produced.
- C) An error will occur.
- D) The integer 5 will be converted to a float.
- 6. Which data type would you typically use to store a person's age (e.g., 30 years old)?
- A) Float
- B) String
- C) Integer
- D) Boolean
- 7. What is the most appropriate data type for storing whether a user is logged in (yes/no)?
- A) String
- B) Integer
- C) Float
- D) Boolean
Click to see Answers
1. C (42 is a whole number without quotes or decimals.)
2. C (0.001 has a decimal point.)
3. C (Enclosed in double quotes, it's a sequence of characters.)
4. C (False is a literal boolean value; "False" is a string.)
5. C (Direct addition of different, incompatible types usually results in a TypeError.)
6. C (Age is typically a whole number.)
7. D (A Boolean value can represent true/false, yes/no states.)