标签:put col ima 雪花 alt mamicode com == src
#字符串反转 def ves(s): if s==‘‘: return s else: return ves(s[1:])+s[0] s=input() print(s[::-1]) print(ves(s)) ‘‘‘ CAVD DVAC DVAC ‘‘‘
#汉诺塔 cnt =0 def hano(n,st,mid,de): global cnt if n==1: print("{}:{}->{}".format(1,st,de)) cnt+=1 else: hano(n-1,st,de,mid) print("{}:{}->{}".format(n,st,de)) cnt+=1 hano(n-1,mid,de,st) hano(3,‘A‘,‘B‘,‘C‘) print(cnt) 1:A->C 2:A->B 1:C->A 3:A->C 1:B->C 2:B->A 1:C->B 7
#绘制雪花 import turtle def koh(size,n): if n==0: turtle.fd(size) else: for i in[0,60,-120,60]: turtle.lt(i) koh(size/3,n-1) def main(): turtle.setup(600,600) turtle.pu() turtle.goto(-200,100) turtle.pd() turtle.pensize(2) lev =3 koh(400,lev) turtle.rt(120) koh(400,lev) turtle.rt(120) koh(400,lev) turtle.hideturtle() main()
标签:put col ima 雪花 alt mamicode com == src
原文地址:https://www.cnblogs.com/tingtin/p/11870616.html