In one of the previous tutorial, I have discussed about variable declaration. Variable are declared to store values in it. We can store different types of values in a variable. Lets learn in this tutorial, what are the different types of data we can store in a variable.
String
String data type are the general text information which are not numbers or any other type of data.
Example: name=”srikant” address=”Yari Road, Mumbai”
Integer
The numbers which are not decimal.
Example: age=30 number_of_students=110
Float
Numbers which are decimals only.
Example: weight=78.9 price: 88.99
Boolean
There are values which is always either true or false. So such values are known as Boolean.
Example: DoesSheSpeakEnglish=False EmployeeDeservesHoliday=True
List
In python, we have list. List are group of different types of data values. If we want to store all the names of students of class tenth in a single variable then that would be a list. List is very powerful and very important concept in the world of python programming.
Example: FruitNames=[“Banana”,”Orange”,”Apple”,”Grape”]
Dictionary
In some cases we may want to store key and value pair data in a variable. Such variable is known as dictionary. For example, i want to store name and respective telephone number then I must have to opt dictionary.
Example: {“name”:”will smith”,”phone”:”0088998899″}
Note: In other programming language, we use keyword to define the type of data stored in a variable name but in Python we are not required to use any keyword. Python engine is so smart that it can understand the type of data a variable contains from the type of data stored in it.