作业1:给定一个10个元素的列表,请完成排序(注意,不要使用系统api)
listx = [2002, 5, 12, 2, 25]
def test_1(ls):
for i in range(len(ls) - 1):
for j in range(len(ls) - 1):
if ls[j] > ls[j + 1]:
ls[j], ls[j + 1] = ls[j + 1], ls[j]
return ls
listy = test_1(listx)
print(listy)
作业2:求 a+aa+aaa+.......+aaaaaaaaa=?其中a为1至9之中的一个数,项数也要可以指定。
a = int(input("请输入数字 a:"))
count = int(input("请输入几个数相加:"))
def test_2(a, count):
num = 0
for i in range(1, count + 1):
t = 0
for j in ran