-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex3.py
More file actions
33 lines (23 loc) · 896 Bytes
/
ex3.py
File metadata and controls
33 lines (23 loc) · 896 Bytes
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
print("I will now count my chickens:")
# Order of operations important
# Python follows PEMDAS
# Parentheses, Exponents, Multiplication and Division (left to right), Addition and Subtraction (left to right)
print("Hens", 25 + 30 / 6)
print("Roosters", 100 - 25 * 3 % 4)
print("Now I will count the eggs:")
# division, modulus, then addition and subraction
# modulus fits into the "MD" in PEMDAS
print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)
# no parenthesis, so order of operations
print("Is it true that 3 + 2 < 5 - 7?")
# print the result of the expression
print(3 + 2 < 5 - 7)
# print each side of the expression
print("What is 3 + 2?", 3+2)
print("What is 5 - 7?", 5-7)
print("Oh, that's why it's False.")
print("How about some more.")
# try some other comparison operators
print("Is it greater?", 5 > -2)
print("Is it greater or equal?", 5 >= -2)
print("Is it less or equal?", 5 <= -2)