a = ['one', 'two', 'three']
for i in range(2,-1,-1):
print(a[i])
# for i in a[::-1]:
# print (i)
L = [1,2,3,4,5]
s1 = '-'.join(str(i) for i in L)
print (s1)
def hello_world():
print('hello world')
def three_hellos():
for i in range(3):
hello_world()
if __name__ == '__main__':#如果在本模块调用,则输出,若在另一个模块用import导入,则不输出
three_hellos()
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
print bcolors.WARNING + "警告的颜色字体?" + bcolors.ENDC
l=[]
for i in range(10):
l.append(int(input()))
l.sort()#从小到大
for i in range(10):
print(l[i],end=' ')
print()
l.reverse()#从大到小
for i in range(10):
print(l[i],end=' ')
a = []
sum = 0.0
for i in range(3):
a.append([])
for j in range(3):
a[i].append(float(input('请输入:')))
sum+=a[i][i]
print(sum)
a=[1,4,7,10,15]
n=int(input('请输入:'))
a.append(n)
a.sort()
for i in a:
print(i,end=' ')
a=[1,4,7,10,15]
a.sort()
print(a)
a.reverse()
print(a)
num = 2
def auto():
num = 1
print ('internal block num = %d' % num)
num += 1
for i in range(3):
print ('The num = %d' % num)
num += 1
auto()
X = [[12,7,3],
[4,5,6],
[7,8,9]]
Y = [[5,8,1],
[6,7,3],
[4,5,9]]
Z=[]
for i in range(3):
Z.append([])
for j in range(3):
Z[i].append(X[i][j]+Y[i][j])
print(Z)