Numbers and Mathematics:
Simple python number variables are easy to deal with check below examples of Python 3.
Addition and subsstraction:
Code:
print("""Addition and substraction.""")
print(2+1)
print(1-2)
print(-2+3)
Output:
Addition and substraction.
3
-1
1
Multiplecation and Division:
Code:
print("""Multiplecation and Division.""")
print(2*3)
print(3/2)
Output:
Multiplecation and Division.
6
1.5
To the power:
Code:
print("""To the power.""")
print(2**3)
Output:
To the power.
8
Root over:
Code:
print("""Root over.""")
print(9**0.5)
Output:
Root over.
3.0
Order of operation as per math rule:
Code:
print("Order of operation as per math rule.")
print(2 + 3*3 + 5)
print((2 + 3)*(3 + 5))
Output:
Order of operation as per math rule.
16
40
Variables:
Code:
a=10
b=2
print(a+b)
Output:
12
Variable reassignemnt:
Code:
a=a*a
print(a)
Output:
100
Check type of variable:
Code:
a=10
print ("a type is:",type(a))
b=10.0
print("b type is:",type(b))
Output:
a type is: class 'int'
b type is: class 'float'