python实战练习
1. 九九乘法表:
for i in range(1,10):
r = ''
for j in range(1,i+1):
r = r + str(j) + '*' + str(i) + '=' + str(j*i) + ' '
print r
2. 序列实现冒泡排序:
arr = [2,9,1,6,5,8]
for i in range(len(arr)):
for j in range(i):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
print arr
3. 阶乘:
l = [1,2,3,4,5]
r=1
for i in range(2,len(l)+1):
r *= i
print r
4.猜数字游戏:1-100