如何更正第11行中的无效语法?

2024-09-28 21:59:37 发布

您现在位置:Python中文网/ 问答频道 /正文

python code with invalid syntax in line 11

class bmi():
    def __init__(selfname,height_m,weight_kg):
        self.name = Name
        self.height_m = height
        self.weight_kg = weight

    def from_input(cls):
        return cls(
            input('Enter your name: '),
            print("Hello ", name)
            int(input('User ID: ')),
            int(input('Reputation: ')),
        )

        bmi = weight_kg / (height_m ** 2)
        print(bmi)
        if bmi < 25:
            print( name, "is not overweight")
        else:
            print( name, "is overweight")

Tags: nameselfinputisdefwithcodeint
1条回答
网友
1楼 · 发布于 2024-09-28 21:59:37

python 类bmi(): definit(姓名、身高、体重): self.name=名称 self.height_m=高度 自重×千克=重量

def from_input(cls):
    return cls(
        input('Enter your name: '),
        print("Hello ", name),
        int(input('User ID: ')),
        int(input('Reputation: ')),
    )

    bmi = weight_kg / (height_m ** 2)
    print(bmi)
    if bmi < 25:
        print( name, "is not overweight")
    else:
        print( name, "is overweight")

相关问题 更多 >