資源簡(jiǎn)介 (共12張PPT)Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.少兒編程課BMI計(jì)算器if條件語(yǔ)句x=6if x%2==0:print(x,"是偶數(shù)")else:print(x,"是奇數(shù)")if多重條件語(yǔ)句代碼結(jié)構(gòu)if … :…elif … :…elif … :…if條件語(yǔ)句應(yīng)用x = 0if x > 0:print(x, "是正數(shù)")elif x < 0:print(x, "是負(fù)數(shù)")elif x == 0:print(x, "是零")代碼實(shí)現(xiàn)if多重條件語(yǔ)句代碼結(jié)構(gòu)if … :…elif … :…elif … :…else … :…轉(zhuǎn)換指令將字符串轉(zhuǎn)換為數(shù)值(小數(shù)):float()score=input("請(qǐng)輸入數(shù)學(xué)成績(jī):")score=float(score)print(score)成績(jī)判斷score=input("請(qǐng)輸入數(shù)學(xué)成績(jī):")score=float(score)if score>=90:print("A")elif score>=80:print("B")elif score>=70:print("C")else:print("D")BMI指數(shù)BMI指數(shù)(即身體質(zhì)量指數(shù),簡(jiǎn)稱體質(zhì)指數(shù)又稱體重,英文為Body Mass Index,簡(jiǎn)稱BMI),是用體重公斤數(shù)除以身高米數(shù)平方得出的數(shù)字,是目前國(guó)際上常用的衡量人體胖瘦程度以及是否健康的一個(gè)標(biāo)準(zhǔn)。分析BMI計(jì)算器除法符號(hào) : /height=1.6weight=51num=weight/pow(height,2)print(num)求次冪指令:pow(數(shù)值,次冪)實(shí)現(xiàn)BMI計(jì)算器weight = input("你的體重是多少kg?")weight=float(weight)height =input("你的身高是多少m?")height=float(height)bmi = weight/pow(height,2)print(bmi)實(shí)現(xiàn)BMI計(jì)算器if bmi <=18.4:print("偏瘦")elif bmi < 23.9:print("正常")elif bmi < 27.9:print("過重")elif bmi>=28:print("肥胖") 展開更多...... 收起↑ 資源預(yù)覽 縮略圖、資源來(lái)源于二一教育資源庫(kù)