sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2!=1: # if not x%2:
continue
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2!=1: # if not x%2:
continue
sum+=x
print sum
2018-05-25
sum = 0
x = 1
n = 1
while True:
sum+=x
x*=2
n+=1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum+=x
x*=2
n+=1
if n>20:
break
print sum
2018-05-25
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
print L
L.pop(2)
print L
L.pop(2)
print L
L.pop(2)
print L
2018-05-25
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d['Adam']
print 'Lisa:',d['Lisa']
print 'Bart:',d['Bart']
笨办法,也通过了
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d['Adam']
print 'Lisa:',d['Lisa']
print 'Bart:',d['Bart']
笨办法,也通过了
2018-05-25
在小圆盘上不能放大圆盘,在三根柱子之间一次只能移动一个圆盘....我一直理解的是:"10个盘子,先取9个放C,最后个放到B,然后C的9个放B上面.....愣是想不通"
2018-05-25
我的答案:
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 0,1,2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
for x in [ 1,2,3,4,5,6,7,8,9 ]:
for y in [ 0,1,2,3,4,5,6,7,8,9 ]:
if x<y:
print x*10+y
2018-05-24
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = 100*(x1+x100)/2
print s
正解
d = 3
n = 100
x100 = x1+(n-1)*d
s = 100*(x1+x100)/2
print s
正解
2018-05-24
print 1
print 'Hello,Python'
print 2
print 'Hello',',','Python'
在第二种中自动加空格
print 'Hello,Python'
print 2
print 'Hello',',','Python'
在第二种中自动加空格
2018-05-24
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
d['Paul']= 75
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
d['Paul']= 75
2018-05-24
sum = 0
x = 1
while x<=99:
x=x+2;
for name in x;
sum+=name;
print sum
x = 1
while x<=99:
x=x+2;
for name in x;
sum+=name;
print sum
2018-05-24
# -*- coding: utf-8 -*-
print '每个学生姓名:'
L=['adam','lisa','bart']
for name in L:
print name
print '\n统计平均成绩:'
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum=sum+score
print sum / 4
print '每个学生姓名:'
L=['adam','lisa','bart']
for name in L:
print name
print '\n统计平均成绩:'
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum=sum+score
print sum / 4
2018-05-23