知识点:
在python3中进行数字计算和真值判断. 与C++相同,+,-,/,*,%
程序:
#统计我的鸡
print("I will now count my chickens:")
#母鸡25+30/6=30
print("Hens",25+30/6)
#公鸡100-25*3%4=97
print("Roosters",100-25*3%4)
#统计我的蛋
print("Now I will count the eggs:")
#3+2+1-5+4%2-1/4+6=7
print(3+2+1-5+4%2-1/4+6)
#3+2<5-7 对么?(要不要考虑括号)
print("Is it true that 3+2<5-7?")
#输出3+2<5-7对不对结果:false
print(3+2<5-7)
#分别输出3+2=5 和5-7=-2
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.")
#ture ture false
print("Is it greater?",5>-2)
print("Is it greater or equal?",5>=-2)
print("Is it less or equal?",5<=-2)
输出:
PS C:\Users\xue weiruan\github> python ex3.py
I will now count my chickens:
Hens 30.0
Roosters 97
Now I will count the eggs:
6.75
Is it true that 3+2<5-7?
False
What is 3+2? 5
What is 5-7? -2
Oh, that's why it's False
How about some more.
Is it greater? True
Is it greater or equal? True
Is it less or equal? False
PS C:\Users\xue weiruan\github>