variable


Definition
Guttag (2013) states that variable are way to associate the name with the object. In the variable is a item whose value can be changed or altered. The variable is assigned the values, either it could numeric, string, or sequence.


Examples
Here in this code, a_variable associate is name to object which is "Python", while other variable b_variable are created which assigned the name "Lake". These two objects are joined in python by math operators (+).
 >>> 
>>> a_variable="Python"
>>> b_variable="Lake"
>>> a_variable+b_variable
'PythonLake'
>>>

Following example, we conducted the comparison which is operator through operator == turns false output. Michael (2010) states that python store the assigned name and object associated with in the computer and use it when the operation is called. 
 >>> a_variable.count(str())==b_variable.count(str())
False

variable=string
Here in this code, the python performed string functions on the variable by converting the variable to upper case. 
 >>> 
>>> a_variable="Python"
>>> b_variable="Lake"
>>> a_variable.upper()
'PYTHON'
>>> b_variable.upper()
'LAKE'

variable equality 
Here in this code, two variable are created and tested and print command through if statement to subject to these variables which produced output else statements.
>>> a_variable="Python"
>>> b_variable="Lake"
>>> if a_variable.count(str())==b_variable.count(str()):
            print("Both names has same characters")
    else:
            print("Name does not match") 
>>>
Name does not match
>>>


If statement return with:
name1="Pythonlake"
if name1.endswith("e"):
print("Name character end with 'e'")
else:
print("No, ending character is different")
>>> 
Name character end with 'e'

operator.ilshift(variable_a,variable_b)
The returns is:
  >>> variable_a=55
>>> variable_b=10
>>> operator.ilshift(variable_a,variable_b)
56320


operator.mul(variable_a,variable_b)
The method returns with:
 >>> variable_a=55
>>> variable_b=33
>>> operator.mul(variable_a,variable_b)
1815


The operator method return the value to negative.
 >>>import operator
>>>variable_a=39
>>> operator.neg(variable_a)
-39

References
John Guttag(2013). Introduction to Computation and Programming Using Python. MIT Press, 11.

Michael Dawson(2010). Python Programming for the Absolute Beginner, Third Edition. Cengage Learning, 138.
Comments