Python for Data Science : Data Types

Data Types

Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.
  • A data type is a classification that allows specifying which type of value a variable contains.
  • It also allows us to determine what type of mathematical operations can be applied to any given data.
  • There are different types of python data types some of which are integer, float, string, lists, dictionaries, etc.
  • The integer value is a positive or negative whole number.
  • The float value is a real number with floating-point representation.
  • The string value is a sequence of characters.
  • A list can contain data of different data types.
  • A dictionary is an ordered set of a key-value pair of items.
  • Other data types include tuples and sets. 

    Example 1:

     

    # Dynamically-inferred types
    = 20
    print(type(x))
    = '20'
    print(type(x))
    = 20.0
    print(type(x))

Output:

No comments

Powered by Blogger.