Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update 02-添加属性’.py #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tianxintian wants to merge 1 commit into IEdison:master
base: master
Choose a base branch
Loading
from tianxintian:patch-1
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions day14-面向对象基础3/02-添加属性’.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
类的多态:继承产生多态。
"""

# 练习
"""
声明人类,有属性,名字,年龄,性别,身高
要求创建人的对象的时候可以给名字和性别赋初值

再创建学生类继承自人类,拥有人类的所有的属性,再添加学号,成绩,电话属性
要求创建学生对象的时候可以给名字,年龄,电话赋初值
"""

class Person(object):
"""人类"""
def __init__(self, name='', age=0, sex=''):
Expand Down Expand Up @@ -53,12 +62,5 @@ def eat(self):
student1 = Student('胡晨宇', 22, '男')
print(student1)

# 练习
"""
声明人类,有属性,名字,年龄,性别,身高
要求创建人的对象的时候可以给名字和性别赋初值

再创建学生类继承自人类,拥有人类的所有的属性,再添加学号,成绩,电话属性
要求创建学生对象的时候可以给名字,年龄,电话赋初值
"""

AltStyle によって変換されたページ (->オリジナル) /