Variables and Types
Variables and Types
When we create a program, we often like to store
values so that it can be used later. We use objects to capture data, which then
can be manipulated by computer to provide information. By now we know that
object/ variable is a name which refers to a value.
Every object has:
An Identity - can be
known using id (object)
A type – can
be checked using type (object) and
A value – any value
Identity of the object:
It is the object's address in memory and does not change once
it has been created.
Type (i.e data type):
It is a set of values, and the allowable operations on those values.
It can be one of the following:
1. Number
Number data type stores Numerical Values. This data type is
immutable i.e. value of its object cannot be changed (we will talk about this
aspect later). These are of three different types:
a) Integer & Long
b) Float/floating point
c) Complex
Range of an integer in Python can be from -2147483648 to
2147483647, and long integer has unlimited range subject to available memory.
We can know the largest integer in our version of Python by
following the
given set of commands:
Integers contain Boolean Type which is a unique data type,
consisting of two constants, True
& False. A Boolean True value is Non-Zero, Non-Null and Non-empty.
>>> flag = True
>>> type(flag)
<type
'bool'>



Comments
Post a Comment