variable(numeric)


Definition
John( 2014) states that in Python, numeric variable are number whom value are subject to change. The user can change the value any time. The informed store in the variable could be numeric ,string or boolean type or it could be any other type as defined by the user.

Examples
The data is stored in variable name "a" whose value is declared equal to 443. The value stored in the a is numeric type and python performed the requested calculation on the variables.
 >>>
>>> a=443
>>> b=223
>>> a+b
666

In this code, the numeric variable values are tested on the comparison test.
 
>>> 
>>> a=43
>>> b=55
>>> c=34
>>> a+b > a+b+c/4
False

The output is:
 >>> x="5552"
>>> y=233
>>> y+.int(x)
>>> y+int(x)
5785

Here in this sample code the variable assigned the numeric ranges and and if statement is tested on these variables.
a=range(1,18)
b=range(18,40)
c=range(40,99)
print("Please enter your age")
d=input()
if d is a:
    print("You're authorized to work")
elif d is b:
    print ("You are authorized to work")
else:
    print("You can request accommodation")

>>>
Please enter your age

28
You can request accommodation
>>>

Reference
John Paul Mueller( 2014). Beginning Programming with Python For Dummies. John Wiley & Sons. Chapter 5.






Comments