Python 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. Following are the standard or built-in data type of Python:


Numeric: 
    In Python, numeric data type represent the data which has numeric value. Numeric value can be integer, floating number or even complex numbers. These values are defined as int, float and complex class in Python.


Mapping (Dictionary): 
    A dictionary is an unordered collection of key-value pairs which are separated by a colon and enclosed within curly braces {}.
  • Item() method: Returns list of a dictionary’s key-value pairs. The syntax is: dict.items(
                  x = {1:"abc",2:"def",3:"ghi"}
        x.items()
                
        Output: 
          dict_items([(1, ‘abc’), (2, ‘def’), (3, ‘ghi’)])

  • Values() method: Returns a list of dictionary values. The syntax is: dict.values()
    y = {1:"xyz",2:"aeiou",3:"uvw"}
    y.values()
        Output: dict_values(['xyz', 'aeiou', 'uvw'])

  • Keys() method: Returns a list of dictionary keys. The syntax is: dict.keys()
    dict_one = {'animal': 'tiger', 'age':4, 'location':'Cage 5'}
   dict_one.keys()
     
    Output: dict_keys([‘animal’, ‘location’, ‘age’])


If you have any doubts, feel free to post it in comment Section. 

 



Comments

Popular posts from this blog

Find the final amount after Discount

Simple Arithmetic Calculator - User Defined Function

Guessing the Number Game