x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
s1=x1*n+n*(n-1)*d/2
print s,s1 我第一次的时候把x1乘n写成了nx1,完全受到数学的影响
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2
s1=x1*n+n*(n-1)*d/2
print s,s1 我第一次的时候把x1乘n写成了nx1,完全受到数学的影响
2016-03-26
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
2016-03-26
print 'hello,','python'
print 'hello, python'
print 'hello,python'
print 'hello'',python'
print 'hello',',python'
结果空格的位置不一样
print 'hello, python'
print 'hello,python'
print 'hello'',python'
print 'hello',',python'
结果空格的位置不一样
2016-03-26
a=45678+0x12fd2
b='learn python in imooc'
c=100<99
d=0xff==255
print a,b,c,d
b='learn python in imooc'
c=100<99
d=0xff==255
print a,b,c,d
2016-03-26
L = ['Adam', 95.5, 'Lisa', 85, 'Bart', 59]
L.append('paul')
L.append(66)
L.insert(0,'Lee')
L.insert(1,100)
L.insert(-2,'tom')
L.insert(-2,33)
L.pop(11)
L.pop(10)
L.pop(9)
L.pop(8)
print L
L.append('paul')
L.append(66)
L.insert(0,'Lee')
L.insert(1,100)
L.insert(-2,'tom')
L.insert(-2,33)
L.pop(11)
L.pop(10)
L.pop(9)
L.pop(8)
print L
2016-03-26
用学到这一节的内容为止,下面应该是符合要求的答案中效率最高的一个,只是跟它默认答案顺序不同而已
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 9,8,7,6,5,4,3,2,1,0 ]:
if x < y:
print x*10 + y
else:
break
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 9,8,7,6,5,4,3,2,1,0 ]:
if x < y:
print x*10 + y
else:
break
2016-03-26
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x100+x1)*n/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x100+x1)*n/2
print s
2016-03-26