2020.1.2

# text9-3

class user():
    def __init__(self , first_name , last_name , adress, tel , email):
        self.first = first_name
        self.last = last_name
        self.adress = adress
        self.tel = tel
        self.email = email
    
    def describe_user(self):
        print("用户名字叫:" + self.first + self.last)
        print("现在居住:" + self.adress)
        print("电话:" + self.tel)
        print("E-mail:" + self.email)
        
    def greet_user(self):
        """
        input("你的个人资料有变更吗?")      
        input("如果需要变更个人信息,请输入‘变更’)
        """
        print("\n还有什么不明白的吗?\n")
        
        
wang = user('王', '晓静' , '北京通州区' , '130012345567' , '999999@qq.com')
print("\n" + wang.first + wang.last + "\n现在住在" + wang.adress + "\n电话号码是: " + wang.tel + "\n邮箱是:" + wang.email + "\n")
wang.describe_user()
wang.greet_user()

rita = user('张' , '腾' , '北京海淀' , '19000008877' , 'zzzzzyyyyy@163.com')
rita.describe_user()
rita.greet_user()

xixi = user('赵' , '朝阳' , '北京丰台' , '1234567890' , 'happy_face@yahoo.com')
xixi.describe_user()
xixi.greet_user()
100.
class Car():          # 创建一个car类
    """一次模拟汽车的简单尝试"""
    
    def __init__(self , make , model , year):  # 创建一个__init__方法
        """初始化描述汽车的属性"""        # 把方法中属性储存在根据这个类创建的属性中
        self.make = make
        self.model = model
        self.year = year
        
    def get_descriptive_name(self):      # 创建一个类,用来描述属性
        """返回正解的描述性信息"""
        long_name = str(self.year) + " " + self.make + " " + self.model
        return long_name.title()
    
my_new_car = Car('audi' , 'a4' , 2016)      # 创建一个实例
print(my_new_car.get_descriptive_name())
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值