左边那个age的问题是因为20也满足第一个if的条件所以会输出teenager,相当于被第一个判断语句给 截胡 了。第一个判断语句加上and age<18就OK了
2018-04-21
我的想法是t = ('a', 'b', [('A'), ('B')]),把tuple中的list中的元素变成单个tuple
2018-04-21
sum = 0
x = 1
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
sum+=x
print sum+1
x = 1
while True:
x = x + 1
if x > 100:
break
if x%2==0:
continue
sum+=x
print sum+1
2018-04-21
sum = 0
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
2018-04-21
def average(*args):
av=0.0
for i in args:
av=float(sum(args))/len(args)
return av
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
看了看没有比我简单的了
av=0.0
for i in args:
av=float(sum(args))/len(args)
return av
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
看了看没有比我简单的了
2018-04-21
sum = 0
x = 0
n = 1
while True:
sum=pow(2,x)+sum
if(n==20):
break
n=n+1
x=x+1
print sum
x = 0
n = 1
while True:
sum=pow(2,x)+sum
if(n==20):
break
n=n+1
x=x+1
print sum
2018-04-21
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
print s
2018-04-21
s='\tPython was started in 1989 by \"Guido\".\n\tPython is free and easy to learn.'
print s
print s
2018-04-21