# 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())