1.
A = ['一','二','三']
if len(A) % 2 == 0:
a = A[int(len(A) / 2)]
b = A[int((len(A)) / 2 - 1)]
print(b,a)
else:
c = A[int(len(A) / 2)]
print(c)
print('==========')
2.
list = [1,2,3,]
sum = 0
for x in list:
y = int(x)
sum += y
print(sum)
print('==============')
3.
list = [1,2,3,4,5,6,7]
for index in range(0,len(list)):
if index % 2 != 0:
print(list[index])
print('==============')
4.
list = [1,2,3,4,5,6,7,8,9]
for x in list:
if x % 2 != 0:
print(x)
print('==============')
5.
list = [1,2,3,4,5,6]
for x in list:
x *= 2
print(x)
print('==============')
6.
list = ['abc','123','aaa']
for index in range(0,len(list)):
if index > 0:
list[0] += list [index]
print(list[0])
7.
A = ['a','A','b','B','c','C']
B = []
C = []
for index in range(0,len(A)):
if index % 2 != 0:
B1 = A[index]
B.append(B1)
else:
C1 = A[index]
C.append(C1)
print(B,C)
8.
A = [1,2,3,4,5,6,7,8,9]
B = [0]
for index in range(0,len(A)):
if index <= 4:
a = A[index]
B.append(a)
print(B)
网友评论