如下操作和参考代码之间结果都是对的,但是取值的过程截然不同,擦!
def firstCharUpper(s):
return s.upper()[:1]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
def firstCharUpper(s):
return s.upper()[:1]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2019-06-12
x = 0
while True:
x = x + 1
if x > 100:
break
elif x%2==0:
continue
else:
sum+=x
print sum
while True:
x = x + 1
if x > 100:
break
elif x%2==0:
continue
else:
sum+=x
print sum
2019-06-12
'''
sum =0
for i in range(101):
p=i*i
sum=sum+p
print sum
'''
'''
sum=0
L=range(101)
for i in L:
p=L[i]*L[i]
sum=sum+p
print sum
'''
'''
sum=0
n=1
while n<101:
sum=sum+n*n
n=n+1
print sum
'''
L=[]
x=1
while x<101:
L.append(x*x)
x=x+1
print sum(L)
sum =0
for i in range(101):
p=i*i
sum=sum+p
print sum
'''
'''
sum=0
L=range(101)
for i in L:
p=L[i]*L[i]
sum=sum+p
print sum
'''
'''
sum=0
n=1
while n<101:
sum=sum+n*n
n=n+1
print sum
'''
L=[]
x=1
while x<101:
L.append(x*x)
x=x+1
print sum(L)
2019-06-11
for x in range(1,10) :
for y in range(1,10) :
if x<y:
print(x*10+y)
for y in range(1,10) :
if x<y:
print(x*10+y)
2019-06-04
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:
continue
print x+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:
continue
print x,y
for y in [ '0','1','2','3','4','5','6','7','8','9' ]:
if x>=y:
continue
print x+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:
continue
print x,y
2019-06-04