Understanding Variables and their General Data Types


Let us first understand what are variables:

Variables:

A variable is an alphabetic character whose value is unknown or is bound to change. It is assigned an address in the memory of the computer and its value can be transferred to other variables as well.

Integers:

Integer is any number without the decimal point. Mathematical operations can be performed on variables.
Integers, when operated with a float, are upgraded to floating point numbers.

Floating Point Numbers:

All numbers with a decimal point come in this category. This is a separate data type because that dot requires more space in memory. 

Strings:

Strings include all text inside inverted commas, that is single quotes or double quotes. Mathematical operations cannot be performed without converting them to integers or floats.

Declaring A Variable:

A variable can be declared as follows:
a=3
b=4
s="3"
print(a,b)
print(a+b, s)
Result:
3 4
7 3
where the assignment operator is "=".

Comments