python基础试题

‘‘‘打印三角行;------------lines = int(input(‘请输入行数:‘))for i in range(lines):    for j in range(i):        print("*",end= ‘ ‘)    print()‘‘‘‘‘‘打印倒立三角行;lines = int(input(‘请输入行数:‘))for i in range(lines):    j = 0    while j < lines-i:        print("*",end= ‘ ‘)        j += 1    print()‘‘‘# 打印九九乘法表---------------------‘‘‘i = 1while i <= 9:    j = 1    while j <= i:        print(‘%d * %d = %d‘ %(j,i,j*i),end= ‘ ‘)        j += 1    i += 1    print()‘‘‘# # 求1000以内的水仙花数--------------------‘‘‘for i in range(100,1000):    m = i // 100    n = i // 10 % 10    p = i % 10    if (m ** 3) + (n ** 3) +(p ** 3) == i:        print(i,end=‘,‘)‘‘‘# 求1-100以内所有偶数的和------------------‘‘‘sum = 0i = 1while i <= 100:    if i % 2 == 0:        sum += i    i += 1print(sum)# 获取用户输入的任意数,判断其是否是质数?-----------------num1 = int(input(‘请输入一个整数‘))i = 2while i < num1:    if num1 % i == 0:        print(num1,"不是质数")        print(i,"*",num1//i,"是",num1)        break    i += 1else:    print(num1,"是质数")‘‘‘# n = int(input("请输入一个数字:")) # ------------‘‘‘j = 2while j < n:    if n % j == 0:        print(n,‘不是质数‘)        print(j,"*",n//j,‘是‘,n)        break    j += 1else:    print(n,"是质数")‘‘‘# 打印出100 以内的质数 ------------------‘‘‘num = []j = 2for i in range(2,100):    for j in range(2,i):        if i % j == 0:            break    else:        num.append(i)print(num)‘‘‘