Skip to content
Question 89 of 97

Q.Write the names of any four data types available in Python.

Tamil Nadu DgeCBSE Class XII Board 2019Subjective· 2mImportance★★★★★
92% · 89/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Python uses data types to classify values, determining their nature and the operations they support; four fundamental types are integers (int), floating-point numbers (float), strings (str), and booleans (bool).

Concept and Intuition

In programming, a data type is essentially a classification that tells the computer what kind of value a variable holds. Think of it like sorting items into different bins: one bin for numbers, another for text, another for true/false statements, and so on. Each bin (data type) has specific rules about what you can put in it and what you can do with its contents.

For example, you can perform arithmetic operations (addition, subtraction) on numbers, but it doesn't make sense to "add" two pieces of text in the same way. Knowing the data type helps the computer allocate appropriate memory and understand which operations are valid.

Python is a dynamically typed language, which means you don't explicitly declare the type of a variable when you create it. Instead, Python automatically infers the type based on the value you assign. However, every value in Python still has a specific data type, and understanding these types is crucial for writing correct and efficient code.

Step-by-Step Explanation of Four Data Types

Here are four common and fundamental data types available in Python:

  1. Integers (int)

    Integers are whole numbers, positive or negative, without a decimal point. They can be of arbitrary precision, meaning Python can handle very large integers without overflow issues (unlike some other languages).

    • Reasoning: Used for counting, indexing, or any scenario where fractional parts are not relevant.
    • Example:
      age = 30
      year = -2023
      big_number = 12345678901234567890
      print(type(age)) # Output: <class 'int'>
      
  2. Floating-Point Numbers (float)

    Floating-point numbers represent real numbers and are written with a decimal point. They are used when precision beyond whole numbers is required.

    • Reasoning: Essential for calculations involving fractions, measurements, or scientific data.
    • Example:
      price = 19.99
      pi_value = 3.14159
      temperature = -5.5
      print(type(price)) # Output: <class 'float'>
      
  3. Strings (str) …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.