65.题目:一个最优美的图案
#65
import math
class PTS:def __init__(self):self.x = 0self.y = 0
points = []def LineToDemo():import tkinter screenx = 400screeny = 400canvas = Canvas(width = screenx,height = screeny,bg = 'white')AspectRatio = 0.85MAXPTS = 15h = screenyw = screenxxcenter = w / 2ycenter = h / 2radius = (h - 30) / (AspectRatio * 2) - 20step = 360 / MAXPTSangle = 0.0for i in range(MAXPTS):rads = angle * math.pi / 180.0p = PTS()p.x = xcenter + int(math.cos(rads) * radius)p.y = ycenter - int(math.sin(rads) * radius * AspectRatio)angle += steppoints.append(p)canvas.create_oval(xcenter - radius,ycenter - radius,xcenter + radius,ycenter + radius)for i in range(MAXPTS):for j in range(i,MAXPTS):canvas.create_line(points[i].x,points[i].y,points[j].x,points[j].y)canvas.pack()mainloop()
if __name__ == '__main__':LineToDemo()
输出:
66.题目:输入3个数a,b,c,按大小顺序输出
#66
n1 = int(input('n1 = :'))
n2 = int(input('n2 = :'))
n3 = int(input('n3 = :'))def swap(p1,p2):return p2,p1if n1 > n2 : n1,n2 = swap(n1,n2)
if n1 > n3 : n1,n3 = swap(n1,n3)
if n2 > n3 : n2,n3 = swap(n2,n3)print (n1,n2,n3)
输出:
当然,除了上面的排序害可以直接用 sort 进行排序输出