What is the difference between all variables available in python?

882    Asked by SuzannaHinojos in Data Science , Asked on Dec 6, 2019
Answered by Suzanna Hinojos

 In python, there are 5 types of variable or data type, that are number, string, list, tuple, and dictionary.

Number: Variable which stores numeric data is called numeric variable or data type

  n = 1

String: Variable which stores character data is called string data type

  s = ‘janbask’

List: It is an ordered sequence of items and most used in python. All items do not need to of the same type.

  l = [1,2,3,4,5,6,'<a href="https://www.janbasktraining.com/">janbask</a>']

Tuple: Tuple is also an ordered sequence of items like List, but the only difference is tuple is immutable. Tuples once created cannot be modified. They are used to protect data and are usually faster than a list.

  T = (1,2,3,4,5,6,'janbask')

Dictionary: Dictionary is an unordered sequence of key-value pairs. We use {} braces to define a dictionary in python and generally used when we have a huge amount of data.

D = {1:'value','key':2}

Your Answer

Interviews

Parent Categories