sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x * 2
n = n + 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
x = x * 2
n = n + 1
if n > 20:
break
print sum
2019-05-15
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
2019-05-15
print 'hello, python.'
print 'hello,','python.'
print 'hello,','python.'
2019-05-15
# -*- coding: utf-8 -*-
print '''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print '''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2019-05-15
最后一道题6-10set更新,综合了一下前面的for和if
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for L1 in L:
if L1 in s:
s.remove(L1)
else:
s.add(L1)
print s
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for L1 in L:
if L1 in s:
s.remove(L1)
else:
s.add(L1)
print s
2019-05-13
sum = 1
x = 1
while True:
x=x+1
if x>100:
break
if x%2==0:
continue
sum=sum+x
print sum
x = 1
while True:
x=x+1
if x>100:
break
if x%2==0:
continue
sum=sum+x
print sum
2019-05-13
if score>=90:
print 'excellent'
elif score>=80:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
python的语法都不用写成elif score>=80&&score<90 么
print 'excellent'
elif score>=80:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
python的语法都不用写成elif score>=80&&score<90 么
2019-05-11