print "I will now count my chickens:"
print "Hens", 25 + 30 / 6
print "Roosters", 100 -25 * 3 % 4 # “%”是求余符號(hào)
print "Now I will count the eggs:"
print 3 + 2 +1 - 5 + 4 % 2 - 1 / 4 + 6
print "Is it true that 3 + 2 < 5 - 7?"
print 3 + 2 < 5 - 7
print "What is 3 + 2?", 3 + 2
print "What is 5 - 7?", 5 - 7
print "Is it greater?", 5 > -2
print "Is it greater or equal?", 5 >= -2
print "Is it less or equal?", 5 <= -2
輸出
I will now count my chickens:
Hens 30
Roosters 97
Now I will count the eggs:
7
Is it true that 3 + 2 < 5 - 7?
False
What is 3 + 2? 5
What is 5 - 7? -2
Is it greater? True
Is it greater or equal? True
Is it less or equal? False
print "I will now count my chickens:"
print "Hens", 25.0 + 30.0 / 6 #換成浮點(diǎn)數(shù)再運(yùn)行一次
print "Roosters", 100.0 -25.0 * 3 % 4
print "Now I will count the eggs:"
print 3.0 + 2 +1 - 5 + 4.0 % 2 - 1.0 / 4 + 6
輸出
I will now count my chickens:
Hens 30.0
Roosters 97.0
Now I will count the eggs:
6.75