第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

名稱(變量名)未定義錯誤

名稱(變量名)未定義錯誤

慕標(biāo)5832272 2023-09-12 17:50:29
這應(yīng)該有效:import pandas as pddf_ex = pandas.read_csv('ex.csv', sep=',')latitude_diff_list, longitude_diff_list = [], []for idx,row in df_ex[1:].iterrows():    if abs(row['latitude'] - df_ex.loc[idx-1, 'latitude']) > 0.1:        latitude_diff_list.extend([idx-1, idx])    if abs(row['longitude'] - df_ex.loc[idx-1, 'longitude']) > 0.1:        longitude_diff_list.extend([idx-1, idx])latitude_diff_list, longitude_diff_list = list(set(latitude_diff_list)), list(set(longitude_diff_list))分享
查看完整描述

5 回答

?
慕神8447489

TA貢獻1780條經(jīng)驗 獲得超1個贊

您可以將其放入一個類中,其中每個對象都存儲每個人的體重數(shù)據(jù)。


class bmi_profile:

    def __init__(self, name, weight_kg, height_m):

        self.name = name

        self.weight_kg = weight_kg

        self.height_m = height_m

        self.bmi_result = weight_kg / (height_m ** 2)

  

    def print_bmi(self):

        print(self.name, end = ' ')

        if self.bmi_result < 25:

            print('Is not overweight!')

        else:

            print('Overweight!')


name = input('Name: ')

weight = float(input('Weight(Kg): '))

height = float(input('Height(M): '))


profile = bmi_profile(name, weight, height)

profile.print_bmi()

輸出:(在 后輸入:)


Name: Jon

Weight(Kg): 60

Height(M): 1.80

Jon Is not overweight!


查看完整回答
反對 回復(fù) 2023-09-12
?
慕桂英4014372

TA貢獻1871條經(jīng)驗 獲得超13個贊

# My first try

def profile():

  global weight_kg, height_m, name

  name = input('Name: ')

  weight_kg = int(input('Weight(Kg): '))

  height_m = int(input('Height(M): '))




def bmi_result():

    print(name)

    if bmi_converter < 25:

        print('Is not overweight!')

    else:

        print('Overweight!')


profile()


bmi_converter = (weight_kg / (height_m ** 2))        


bmi_result()

不錯的嘗試,喬恩。您需要使用全局變量才能工作。另外,您忘記引用正確的變量bmi_converter

https://img1.sycdn.imooc.com//6500349b00019b8201910106.jpg

查看完整回答
反對 回復(fù) 2023-09-12
?
翻翻過去那場雪

TA貢獻2065條經(jīng)驗 獲得超14個贊

你可以試試這個:


def profile():

    name = input('Name: ')

    weight_kg = int(input('Weight(Kg): '))

    height_m = int(input('Height(M): '))

    bmi_converter(weight_kg, height_m, name)



def bmi_converter(weight_kg, height_m, name):

    bmi = weight_kg / (height_m ** 2)

    bmi_result(bmi, name)



def bmi_result(bmi, name):

    print(name)

    if bmi < 25:

        print('Is not overweight!')

    else:

        print('Overweight!')



profile()


查看完整回答
反對 回復(fù) 2023-09-12
?
鳳凰求蠱

TA貢獻1825條經(jīng)驗 獲得超4個贊

您的weight_kg、height_m 和name 變量范圍位于profile 函數(shù)中。所以它們不能用于其他功能。您可以使用這些變量作為參數(shù)。


    def profile():

        name = input('Name: ')

        weight_kg = int(input('Weight(Kg): '))

        height_m = int(input('Height(M): '))

        bmi_converter(name,weight_kg, height_m)

    

    

    def bmi_converter(name,weight_kg, height_m):

        bmi_formula  = weight_kg / (height_m ** 2)

        bmi_result(bmi_formula , name)

    

    

    def bmi_result(bmi, name):

        print(name)

        if bmi < 25:

            print('Is not overweight!')

        else:

            print('Overweight!')

    

    

    profile()


查看完整回答
反對 回復(fù) 2023-09-12
?
SMILET

TA貢獻1796條經(jīng)驗 獲得超4個贊

我終于讓我的代碼工作了,我將你們的一些代碼打亂到我的代碼中,并使其更短、更簡單,如下:


name = input('Name: ')

weight_kg = int(input('Weight(Kg): '))

height_m = int(input('Height(M): '))


def bmi_calculator(name, weight_kg, height_m):

    bmi = weight_kg / (height_m ** 2)

    if bmi < 25:

        print(name +' is not overweight!')

    else:

        print(name +' is overweight!')


result = bmi_calculator(name, weight_kg, height_m)


查看完整回答
反對 回復(fù) 2023-09-12
  • 5 回答
  • 0 關(guān)注
  • 210 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號