Python - Data Types

Python Data type specifies the type of data to be stored in a variable. For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters.

Python has various standard data types:

  1. Numbers: int, float, complex
  2. Bool: Boolean data type is use to store the values either true or false, true also represent value 1, and false represent value 0. Bool keyword is use to declare Boolean data type. Syntax: a=10<5 # bool
  3. String
  4. List
  5. Tuple
  6. Range
  7. Dictionary
a=list(range(10))   #store [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
a=list(range(2,10,2)) #store even nos: start,end,difference

d={'aman':'java', 'suman':'python'} # dictionary
d.keys() # dict_keys(['aman', 'suman'])
d.values() # dict_values(['java', 'python'])
d.get('aman') # value of aman