Variables and DataTypes in Python

Variable

Variable in python is reserved memory location which is used to store data or values. In other words, a variable in a python program gives data to the computer for processing. Declaring and re-declaring a variable in Python is as easy as writing names and assigning values to it.

there are many types of data that get stored like integer, decimal or float, String or text, binary data.so, In order to represent these data in python we use variable with specific name like x,y,z,….

Lets go with Example of BMI (Body Mass Index) :

height = 1.79
weight = 68.7
bmi = weight / height ** 2
print(bmi)

Output : 21.4413

DataTypes

Datatype in python is type of data which we store into system using variables.As we have mentioned earlier there are many datatypes and there can be as many as 4 , 7 or even more datatype depend upon what kind of programming language we use , But In python There are mainly 4 datatypes and rest are mainly objects of class like list, tuple, dictionary about which we will discuss later.

DataTypes in python :

  • integer or int – 1,2,3,4
  • float – 1.23,32.1
  • string – "hello" or 'hello'
  • bool – 1 and 0 or True and False

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑