print表输出
x表示上面set集合s中的一个tuple元素,例如:('Adam', 95)
tuple是一个元组,('Adam', 95)中有两个元素,所以在tuple中的第一个元素的索引是0,第二个是1。所以x[0]表示第一个元素,例如:Adam,x[1]表示第二个元素,例如:95
+的作用是:连接字符或字符串,‘:’就是一个字符
,起到隔开作用
x表示上面set集合s中的一个tuple元素,例如:('Adam', 95)
tuple是一个元组,('Adam', 95)中有两个元素,所以在tuple中的第一个元素的索引是0,第二个是1。所以x[0]表示第一个元素,例如:Adam,x[1]表示第二个元素,例如:95
+的作用是:连接字符或字符串,‘:’就是一个字符
,起到隔开作用
2019-09-05
list is different from tuple.
list has orders.
list element can be replaced by cited position.
list can use append, pop and insert
tuple can not be changed once it is made. but the both can be cited by positions. tuple has no orders
list has orders.
list element can be replaced by cited position.
list can use append, pop and insert
tuple can not be changed once it is made. but the both can be cited by positions. tuple has no orders
2019-09-05
L = range(1, 101)
print L[0:10]
print L[2:101:3]
print L[4:51:5]
print L[0:10]
print L[2:101:3]
print L[4:51:5]
2019-09-02
sum = 0
x = 1
while x < 100:
sum = sum + x
x += 2 #这里x初始为1,每次加2就会变成奇数
print sum
x = 1
while x < 100:
sum = sum + x
x += 2 #这里x初始为1,每次加2就会变成奇数
print sum
2019-09-02
sum = 0
x = 1
while x <= 50:
sum = sum + (2*x-1)
x = x+1
print sum
x = 1
while x <= 50:
sum = sum + (2*x-1)
x = x+1
print sum
2019-09-01
L = ['Adam', 95.5, 'Lisa', 85, 'Bart', 59]
print L 这样就可以通过了
print L 这样就可以通过了
2019-08-30
L = ['Adam', 'Lisa', 'Bart', 'Paul']
N = list(range(1,len(L)+1))
for index, name in zip(N,L):
print index, '-', name
N = list(range(1,len(L)+1))
for index, name in zip(N,L):
print index, '-', name
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-08-30
sum= 0
sum1 =0
x = 1
n = 1
while True:
sum1=sum1+x
x=sum1
sum=sum+sum1
n=n+1
if n>20:
break
print sum
sum1 =0
x = 1
n = 1
while True:
sum1=sum1+x
x=sum1
sum=sum+sum1
n=n+1
if n>20:
break
print sum
2019-08-29