题解 | #修改属性1#

修改属性1

https://www.nowcoder.com/practice/c5ab441e5e8f4ec7bf36ba51a3141340

class employee:
    def __init__(self,name,salary,age=-1):
        self.name=name
        self.salary=salary
        self.age=age
    def printclass(self):
        if self.age==-1:
            print("Error! No age")
        else:
            print("{}'salary is {}, and his age is {}".format(self.name,self.salary,self.age))
a=input()
b=int(input())
c=int(input())
e=employee(a,b)
e.printclass()
e.age=c 
e.printclass()

全部评论

相关推荐

投递亚信科技(中国)有限公司等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务