-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex3.py
60 lines (47 loc) · 1.27 KB
/
ex3.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
ex3.py 数字和数学
+ plus
- minus
* asterisk
/ slash
% percent 取模——取余数
< less-than
<= less-than-equal
> greater-than
>= greater-than-equal
PEMDAS = PE(M&D)(A&S)
Parentheses ()
Exponents ** ( ^ = XOR )
Multiplication *
Division /
Addition +
Subtraction -
"""
# explain what to do next: count chickens
print("I will now count my chickens:")
# print the count of hens
print("Hens", 25.0 + 30.0 / 6)
# print the count of roosters
print("Roosters", 100 - 25.0 * 3 % 4)
# tips that the count of eggs
print("Now I will count the eggs:")
# do some calculating about the number of eggs
print(3 + 2 + 1 - 5 + 4 % 2 - 1.0 / 4 + 6)
# compare 3+2 and 5-7
print("Is it true that 3 + 2 < 5 - 7?")
# print the comparative result: False
print(3 + 2 < 5 - 7)
# calculate the answer of 3+2
print("What is 3 + 2?", 3 + 2)
# calculate the answer of 5-7
print("What is 5 - 7?", 5 - 7)
# print the answer why 3 + 2 is not less than 5 - 7
print("Oh, that's why it's False.")
# print more comparision
print("How about some more.")
# the result whether 5 is greater than -2: True
print("Is it greater?", 5 > -2)
# whether 5 is greater than or equal to -2: True
print("Is it greater or equal?", 5 >= -2)
# whether 5 is less than or equal to -2: False
print("Is is less or equal?", 5 <= -2)