google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Variables and objects in python

Monday, December 16, 2019

Variables and objects in python

Learn variables and objects in python:

In Python, values are stored in objects.
If we do
d = 10.0
a new object d is created. As we have given it a floating point value (10.0) the object is of type floating point.
If we had defined d = 10, d would have been an integer object.
In other programming languages, values are stored in variables.
This is not exactly the same as an object, as an object has "methods", that means functions that belong to the object.

There are many object types in Python.

The most important to begin with are:

Object type: Integer
Type class name: int
Description: Signed integer, 32 bit
Example: a = 5

Object type: Float
Type class name: float
Description: Double precision floating point number, 64 bit
Example:b = 3.14

Object type: Complex
Type class name: complex
Description: Complex number
Example: c = 3 + 5j
  c= complex(3,5)


Object type: Character
Type class name: chr
Description:  Single byte character
Example: d = chr(65)
d = 'A'
d = "A"

Object type: String
Type class name: str
Description: List of characters, text string
Example: e = 'LTAM'
e = "LTAM"

No comments:

Post a Comment

शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...