Python类,试图掌握与其他类相关的函数一起创建类实例的概念

问题描述 投票:0回答:1

请注意,这不是硬件或项目。在网上找到了一份旧考试,并认为应该很好理解进行了一些评论,但对此仍然很模糊。对于如何理解这一点的任何见解将不胜感激。enter image description here

python
1个回答
0
投票
# a
X = City("Chicago", "Illinois")

# b - note this line of code would have to be inside of a function
return X.population

# c
X.county = "Cook"

# d - again, would need to be in a function
return X.state
© www.soinside.com 2019 - 2024. All rights reserved.