Python Data Types

 Python supports several data types, each designed for specific purposes. Here are some of the most commonly used data types in Python with examples:

  1. Integers (int): Integers are whole numbers without a decimal point. Example.  x = 5 y = -10
  2. Floats (float): Floats represent real numbers with a decimal point.Example:  3.14159 temperature = 98.5
  3. Strings (str): Strings are sequences of characters enclosed in single or double quote.    Example:       "Alice" , 'Hello, World!'
  4. Lists (list):Lists are ordered collections of items, which can be of different data types. Example: "apple", "banana", "cherry"] numbers = [1, 2, 3, 4, 5]
  5. Tuples (tuple):Tuples are similar to lists but are immutable (cannot be changed after creation).
  6. Example    (3, 4) colors = ("red", "green", "blue"
  7. Dictionaries (dict):Dictionaries store key-value pairs, allowing you to access values by their keys.
      • Example: {"name": "John", "age": 30, "city": "New York"}
    1. Sets (set):Sets are unordered collections of unique elements.
      • Example: {1, 2, 3, 4, 5} unique_letters = set("hello")
      • Booleans (bool): Booleans represent either True or False.Example:   TRUE.    FALSE
      • None (NoneType): None represents the absence of a value. It is often used to signify that a variable has no value.
        • Example:
        • None
      • Custom Data Types (Classes): You can create your own custom data types using classes in Python.
        • Example:   class Person: def __init__(self, name, age): self.name = name self.age = age person1 = Person("Alice", 25)



          These are the fundamental data types in Python. Python is a dynamically-typed language, meaning you don't need to explicitly specify the data type when declaring a variable. Python determines the data type dynamically based on the value assigned to the variable.









            • pi =




          • =

          • person = 
          • unique_numbers = 



          • ble = 






        Comments

        Popular posts from this blog

        PYTHON SYNTAX

        Python Input and Output Operations

        PYTHON INTRODUCTION:-