1.
def getPentagonalNumber():
for i in range(1,101):
a=i*(3*i-1)/2
if i%10==0:
print("\n")
else:
print("%d"%a,end=" ")
getPentagonalNumber()
2.
def sumDigits(n):
ge = int(n) % 10
c = 0
for i in range(len(str(n))):
bai = int(n) // (10 * (10 ** i)) % 10
c += bai
sum = c + ge
print("这个整数之和是:%d"%sum)
sumDigits(1234)
3.
def lll(a,b,c):
d=[a,b,c]
d.sort()
print(d)
def start():
a=float(input("请输入第一个整数"))
b=float(input("请输入第二个整数"))
c=float(input("请输入第三个整数"))
lll(a,b,c)
start()
4.
from prettytable import PrettyTable
list = []
def futureInvestmentValue(inAmount,rate,years):
for i in range(1,years + 1):
futureInvestment = inAmount + ((1 +rate) ** (12 * i))
list.append([i,futureInvestment])
table = PrettyTable(['year','Future Value'])
for row in list:
table.add_row(row)
print(table)
if __name__ == "__main__":
inAmount = int(input("请输入投资额:"))
rate = float(input("请输入百分比格式的年利率:")) / 12
futureInvestmentValue(inAmount,rate,years = 30)
5.
def printChars():
for i in range(73,91):
print(chr(i),end=" ")
if i%9==0:
print("\n"