没有bug队——加贝——Python 59,60
生活随笔
收集整理的這篇文章主要介紹了
没有bug队——加贝——Python 59,60
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?相關 tkinter 的介紹:Python 55,56
目錄
59.題目:畫圖,綜合例子。 ?
?60.題目:計算字符串長度。 ?
len()函數用法?
59.題目:畫圖,綜合例子。
程序分析:利用for循環控制100-999個數,每個數分解出個位,十位,百位
#59 from tkinter import * canvas = Canvas(width = 300,height = 300,bg = 'green') canvas.pack(expand = YES,fill = BOTH) x0 = 150 y0 = 100 canvas.create_oval(x0 - 10,y0 - 10,x0 + 10,y0 + 10) canvas.create_oval(x0 - 20,y0 - 20,x0 + 20,y0 + 20) canvas.create_oval(x0 - 50,y0 - 50,x0 + 50,y0 + 50) import math B = 0.809 for i in range(16):a = 2 * math.pi / 16 * ix = math.ceil(x0 + 48 * math.cos(a))y = math.ceil(y0 + 48 * math.sin(a) * B)canvas.create_line(x0,y0,x,y,fill = 'red') canvas.create_oval(x0 - 60,y0 - 60,x0 + 60,y0 + 60)for k in range(501):for i in range(17):a = (2 * math.pi / 16) * i + (2 * math.pi / 180) * kx = math.ceil(x0 + 48 * math.cos(a))y = math.ceil(y0 + 48 + math.sin(a) * B)canvas.create_line(x0,y0,x,y,fill = 'red')for j in range(51):a = (2 * math.pi / 16) * i + (2* math.pi / 180) * k - 1x = math.ceil(x0 + 48 * math.cos(a))y = math.ceil(y0 + 48 * math.sin(a) * B)canvas.create_line(x0,y0,x,y,fill = 'red') mainloop()輸出:
?60.題目:計算字符串長度。
#60 sStr1 = 'strlen' print(len(sStr1))輸出:
?
len()函數用法?
描述
Python len() 方法返回對象(字符、列表、元組等)長度或項目個數。
語法
len()方法語法:
len( s )參數
- s -- 對象。
返回值
返回對象長度。
?
總結
以上是生活随笔為你收集整理的没有bug队——加贝——Python 59,60的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 存储过程双层循环_别出心裁,为锂金属负极
- 下一篇: php中reset函数,PHP rese