发布时间:2015-01-17 16:35:19
#找出0~100之间的所有素数from math import sqrtN = 100#基本的方法result1 = []for num in range(2, N): f = True for snu in range(2, int(sqrt(num))+1): if num % snu == 0: f = False .........【阅读全文】
发布时间:2015-01-17 16:09:42
#利用python作为科学计算器。熟悉Python中的常用运算符,并分别求出表达式12*34+78-132/6、(12*(34+78)-132)/6、(86/40)**5的值。并利用math模块进行数学计算,分别求出145/23的余数,0.5的sin和cos值(注意sin和cos中参数是弧度制表示)x = 12*34+78-132/6y = (12*(34+78)-132)/6z = (86/40)**5print ('12*34+78-132/6.........【阅读全文】
发布时间:2015-01-17 15:16:34
判断闰年条件, 满足年份模400为0, 或者模4为0但模100不为0. import timethisyear = time.localtime()[0]if thisyear % 400 == 0 or thisyear % 4 ==0 and thisyear % 100 != 0:print ('this year %s is a leap year' % thisyear)else:print ('this year %s is not a leap year' % thisyear)this year 2015 is .........【阅读全文】