两点疑虑(1)将list中的两个元素A,B改变后,其实list【0】,【1】的指针式改变的,因为先要创建两个新元素xy,在修改指针,对否?
(2)任务中题主意思显然是【】改为()但这样tuple变成内嵌tuple,而不是内嵌list,说不变有点奇异
(2)任务中题主意思显然是【】改为()但这样tuple变成内嵌tuple,而不是内嵌list,说不变有点奇异
2015-07-17
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 * 10 + y
for y in [ 0,1,2,3,4,5,6,7,8,9]:
if x >= y:
continue
print x * 10 + y
2015-07-17
def square_of_sum(L):
sum=0
for num in L:
sum = sum + num
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum=0
for num in L:
sum = sum + num
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-07-17
def firstCharUpper(s):
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-07-16
n=100
x=0
odd=0
while x<n:
if x%2:
odd += x
x += 1
print odd
x=0
odd=0
while x<n:
if x%2:
odd += x
x += 1
print odd
2015-07-16
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key, ':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key, ':',d[key]
2015-07-15
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print "Adam: 95"
print "Lisa: 85"
print "Bart: 59"
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print "Adam: 95"
print "Lisa: 85"
print "Bart: 59"
2015-07-15
for x in range(1,9):
for y in range(0,10):
if x<y:
print x*10+y
for y in range(0,10):
if x<y:
print x*10+y
2015-07-15