模块

bmi.py
def fun_bmi(person,height,weight):
    print(person+'的身高'+str(height)+'米\t 体重:'+str(weight)+'千克')
    bmi=weight/(height*height)
print(person+'的BMI指数为:'+str(bmi))

bmi_.py
import bmi
bmi.fun_bmi('jm',175,100)

rectangle.py
def girth(width,height):
    return (width+ height)*2
def area(width,height):
    return width*height
if __name__=='__main__':
print(area(10,20))

circular.py
import math
PI=math.pi
def girth(r):
    return round(2*PI*r,2)

def area(r):
    return round(PI*r*r,2)
if __name__=='__main__':
print(girth(10))

compute.py
import rectangle as r
import circular as c
if __name__=='__main__':
    print('圆形的周长为:',c.girth(10))
print('矩形的周长为:',r.girth(10,20)

Settings.size.py
__width=800
__height=600
def change(w,h):
    global _width
    _width=w
    global _height
    _height=h
def getWidth():
    global _width
    return _width
def getHeight():
    global _height
return _height

main.py
from settings.size import *
if __name__=='__main__':
    change(1024,768)
    print('宽度:',getWidth())
print('高度:',getHeight())
checkcode.py
import random
if __name__=='__main__':
    checkcode=''
    for i in range(4):
        index=random.randrange(0,4)
        if index!=i and index+1!=i:
            checkcode+=chr(random.randint(97,122))
        elif index+1==i:
            checkcode+=chr(random.randint(65,90))
        else:
            checkcode+=str(random.randint(1,9))
print('验证码:',checkcode)

posted @ 2022-12-16 01:31  核变的思  阅读(41)  评论(0)    收藏  举报