#coding: utf-8
print "I will now count my chickens:" #输入一些语句
print "Hens", 25 + 30 / 6 #输出一句话,同时后面接计算出的数字,用“,”连接
print "Roosters", 100 - 25 * 3 % 4 #%代表取余数符号
print "Now I will count the eggs:" #输出一句话
print 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 #输出数字,注意应该为7.25,只要加入.0即可转换为浮点型
print "Is this true that 3 + 2 < 5 - 7?" #输出一句话
print 3 + 2 < 5 - 7 #返回一个False,由于是判断语句
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."
print "Is it greater?", 5 >= -2 #注意每一个判断语句后的结果都是Ture或False
print "Is it greater or equal?", 5 >=-2
print "Is it less or equal?", 5 <= -2
ex3.py 数字和数学计算
最新推荐文章于 2021-03-26 12:48:17 发布