python
python相关知识
塞北云川
交流进步,火影迷
展开
-
七段数码管绘制
先看结果: 代码如下: import turtle, datetime def drawGap(): #绘制数码管间隔 turtle.penup() turtle.fd(5) def drawLine(draw): #绘制单段数码管 drawGap() turtle.pendown() if draw else turtle.penup() turtle.fd(40) drawGap() turtle.right(90) def drawDigi原创 2020-10-26 17:30:28 · 357 阅读 · 0 评论 -
python实例2:“BMI”测试
利用python检查身高与体重是否正常 代码如下: height, weight = eval(input("请输入身高(米)和体重(公斤)[逗号隔开]:")) bmi = weight / pow(height, 2) print("BMI数值为:{:.2f}".format(bmi)) who, nat = "", "" if bmi < 18.5: who, nat = " 偏瘦 ", "偏瘦" elif 18.5 <= bmi < 24: who, nat = "原创 2020-10-21 14:33:33 · 1182 阅读 · 0 评论 -
python实例1:“文本进度条”
python实例:“文本进度条” 代码如下: import time scale = 50 print("执行开始".center(scale//2,"-")) start = time.perf_counter() for i in range(scale+1): a = '*'* i b = '.'* (scale - i) c = (i/scale)*100 dur = time.perf_counter() - start print("\r{:^3.0f}%原创 2020-10-15 23:05:06 · 983 阅读 · 0 评论