创建关于汽车的类

class Cars():

    def __init__(self, brand, country):
        self.brand = brand
        self.country = country

    def show_brand(self):
        print(self.brand.title() + " is a popular automobile brand.")

    def show_country(self):
        print("Its headquater is in " + self.country.title() + ".")


my_car = Cars('toyota', 'Japan')
my_car.show_brand()
my_car.show_country()

输出

Toyota is a popular automobile brand.
Its headquater is in Japan.
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2021-07-31
  • 2021-04-06
  • 2021-11-21
  • 2022-01-20
  • 2021-11-09
猜你喜欢
  • 2021-08-18
  • 2021-04-25
  • 2021-11-08
  • 2021-11-21
  • 2021-12-22
  • 2021-09-28
  • 2022-12-23
相关资源
相似解决方案