Python Variable and Data types:
In python variable and data types are very interesting, how variable and objects work.In this chapter we will discuss how variable and object are work together in comparison to other languages.In python variable or name is not have a type associated with them.Basically types are only associated with objects and variable are basically just have references these objects.
1
Let us see what’s the meaning of above para:
2
In other language you have to ideally defined string and other types ,In python you don’t need to do this at all. Variable name is just a reference to the objects now this object which is the string “Buffercode” which has a type string associated with it.If you can see the another example. If you are interested to finding out the exact memory location in which the object is stored you can do it in two ways by either using id function or going header using “repr” an attribute inside in a object ,see this example. In using id function it can give the value and you can change into hexadecimal value because in case O.S computer every address is represent in hex value .In use of repr it can automatically represent the current address of an object and type of object. In Python basically many types of data types are there but some mostly Data types are 1. String 2. Number 3. Lists 4. Dictionaries 5. Tuples 6. Boolean …
3
String:
First is the “string ” most familiar among all of the above data types because in every language String is use widely.Multiple method to define a string are:
Unicode String:
Unicode is basically use for standardization because uni-code is referred to wide character allows to encode all of these different letter or languages in an a easy way.
Numbers:
Integer,Float,Double and etc. operators 1. Arithmetic ( +,-*,/ ) 2. x**y (x to the power y) 3. Comparison (>,=,<,<=,>=,==) 4. Bit wise (X|Y ,X&Y,..) 5 .Logical (and, or, not)
Lists:
Lists a collection of objects which can be heterogeneous
4
//