-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHow2IntegersAndOperators.py
39 lines (27 loc) · 1019 Bytes
/
How2IntegersAndOperators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
numSeven = 7
numFour = 4
## Addition
print(numSeven + numFour) #outputs 11
## Subtraction
print(numSeven - numFour) #outputs 3
## Multiplication
print(numSeven * numFour) #outputs 28
## Division
print(numSeven / numFour) #outputs 1.75
## Floor Division - Division that cuts off the decimal without rounding
print(numSeven // numFour) #outputs 1
## Modulo - Division that outputs the remainder
print(numSeven % numFour) #outputs 3
## Powers
print(numSeven**2) #outputs 49
## The Square Root of a number is the same as it taken to the 0.5 power
print(numFour**0.5) #outputs 2
## Python follows order of operations
print(2 + 10 * 10 + 3) #outputs 105
## Parenthesis can override order of operations, as normal
print((2+10) * (10+3)) #outputs 156
## You can use a variable to overwrite itself
numFourteen = numSeven
print("numFourteen equals {}, but we can add it to itself to make it bigger.".format(numFourteen))
numFourteen = numFourteen + numFourteen
print("Now numFourteen equals {}.".format(numFourteen))