#01 - Python Basic Data Types



The basic datatypes availabe in python are as follows:


  1. int = integer(ex. 1, 4,59,0,2,-42,-4 ) all the number from - infinity to + infinity (but all of them are whole numbers)

  2. float = floating points (or decimal numbers) (ex. 1.0 ,340.32, 0.0, -0.4320, ect) all the number from - infinity to + infinity (but all of them are decimal numbers)

  3. bool = boolean it is a special data type which can only have either True or False

  4. str = string litrally anything given between quotation is known as a string .(eg: 'code hub', "5323", "0423.42", '''True''') we can use single quotation (''), double ("") or triple quotation(''' ''')

These are the four basic datatypes available in python. Let's see some example program

  1. # creating 4 variables and storing different datatypes in them
  2. num = 432        # integer
  3. decimal = 20.423 # float
  4. boolean = True   # boolean
  5. string = 'literally anything... inside this quotation'# string
  6. #let's see their datatypes in program , we use type() to know the datatype of a variable
  7. print(type(num))     # gives <class int> as output
  8. print(type(decimal)) # gives <class float> as output
  9. print(type(boolean)) # gives <class bool> as output
  10. print(type(string))  # gives <class str> as output