# coding=utf-8classRestaurant():def__init__(self,restaurant_name,cuisine_type):self.restaurant_name=restaurant_nameself.cuisine_type=cuisine_typedefdescribe_restaurant(self):print"The restaurant's name is {0}".format(self.restaurant_name)print"The restaurant's food style is {0}".format(self.cuisine_type)defopen_restaurant(self):print"The restaurant is opening now."if__name__=='__main__':my_restaurant=Restaurant("厦门沙茶面","福建特色小吃")my_restaurant.describe_restaurant()my_restaurant.open_restaurant()
Text Only
123
The restaurant's name is 厦门沙茶面
The restaurant's food style is 福建特色小吃
The restaurant is opening now.
# coding=utf-8classRestaurant():def__init__(self,restaurant_name,cuisine_type):self.restaurant_name=restaurant_nameself.cuisine_type=cuisine_typedefdescribe_restaurant(self):print"The restaurant's name is {0}".format(self.restaurant_name)print"The restaurant's food style is {0}".format(self.cuisine_type)defopen_restaurant(self):print"The restaurant is opening now."if__name__=='__main__':p1_restaurant=Restaurant("沙县小吃","微辣小炒菜")p1_restaurant.describe_restaurant()p2_restaurant=Restaurant("厦门沙茶面","厦门特色小吃")p2_restaurant.describe_restaurant()p3_restaurant=Restaurant("蜜雪冰城","夏日冰饮")p3_restaurant.describe_restaurant()
Text Only
123456
The restaurant's name is 沙县小吃
The restaurant's food style is 微辣小炒菜
The restaurant's name is 厦门沙茶面
The restaurant's food style is 厦门特色小吃
The restaurant's name is 蜜雪冰城
The restaurant's food style is 夏日冰饮
# coding=utf-8classUser():def__init__(self,first_name,last_name):self.first_name=first_nameself.last_name=last_namedefdescribe_user(self):print"My name is {0}{1}.".format(self.first_name,self.last_name)defgreet_user(self):print"Just wanted to let you know I’m thinking of you. Have a great day!"if__name__=='__main__':p1_user=User("Fanqie","Lan")p1_user.describe_user()p1_user.greet_user()p2_user=User("Yichen","Chen")p2_user.describe_user()p2_user.greet_user()p3_user=User("Keshu","Yi")p3_user.describe_user()p3_user.greet_user()
Text Only
123456
My name is Fanqie Lan.
Just wanted to let you know I’m thinking of you. Have a great day!
My name is Yichen Chen.
Just wanted to let you know I’m thinking of you. Have a great day!
My name is Keshu Yi.
Just wanted to let you know I’m thinking of you. Have a great day!