Skip to content

[oop] 用 __init__ 给对象传参 题目反馈 #310

Description

@Caijintan123

题目 用 init 给对象传参(基础语法的第八章:面对对象的第二题)

我是一名之前没接触过编程的纯新人,在尝试使用您制作的网页学习python时于上题时反复调整print处的空格位置和使用ai工具,但还是无法通过检测过关,在使用“查看答案”还是无法找到问题所在,不清楚是什么情况,特此求解

I'm a complete beginner with no prior programming experience. While trying to learn Python using the webpage you created, I got stuck on the previous question. I repeatedly adjusted the spacing in the  print  statement and even used AI tools, but I still couldn't pass the test. Even after clicking "View Answer," I couldn't figure out what the issue was. I'm not sure what's going on, so I'm reaching out for help.

这是我打出的代码:
class Person:
def init(self, name, age):
self.name = name
self.age = age

def greet(self):
    print(f'我叫 {self.name},今年 {self.age} 岁')

p = Person('张三', 18)
p.greet()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions