Python Data Types

Python Data Types

What is data types?

A python variable can store different types of values, Types of values stored by a variable known as data types.

Classification of data types.

Built-in data types of python are classified as :

1. Text type contains string (str). for example,

  • str :- a = "aman"

2. Numeric types contain integer (int), float and complex. for example,

  • int :- a = 3
  •  float :- b = 4.2
  • complex :- c = 5j

3. Byte types contain bytes, bytearray and memoryview. for example,

  • bytes :- a = b"code"
  •  bytearray :-  b = bytearray (2)
  • memoryview :- c = memoryview (bytes (6))

4. Boolean types contain True and False. for example,

  • True :- a = True
  • False :- b = False

5. None type contains None. for example,

  • None :- a = None

6. Sequence types contain list, tuple and range. for example,

  • list :- a = [ "table" , "chair" , "book" , "pen" ]
  • tuple :- b = ( "book" , "copy" , "pen" )
  • range :- c = range(5)

7. Set types contain set and frozenset. for example, 

  • set :- a = { "ram" , "sita" , "shyam" }
  • frozenset :- b = frozenset({ "tv" , "phone" , "computer" })

8. Mapping type contains dictionary (dict). for example,

  • dict :- a = { "company" : "google" , "name" : "Abhi" , "age" : 28 }



Give a example of float in comment section.

Comments