Coding/Python

[python] ํด๋ž˜์Šค ํ€ด์ฆˆ

๊น€์œ ๋‹ˆ์ฝ˜ 2021. 11. 3. 13:35

# ์ด 3๋Œ€์˜ ๋งค๋ฌผ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
# ๊ฐ•๋‚จ ์•„ํŒŒํŠธ ๋งค๋งค 10์–ต 2010๋…„
# ๋งˆํฌ ์˜คํ”ผ์Šคํ…” ์ „์„ธ 5์–ต 2007๋…„
# ์†กํŒŒ ๋นŒ๋ผ ์›”์„ธ 500/50 2000๋…„



class House:
#๋งค๋ฌผ ์ดˆ๊ธฐํ™”
def __init__(self, location, housetype, deal_type, price, completion_year):
self.location = location
self.housetype = housetype
self.deal_type = deal_type
self.price = price
self.completion_year = completion_year

def show_detail(self):
print(self.location, self.housetype, self.deal_type\
,self.price, self.completion_year)

houses = []
house1 = House("๊ฐ•๋‚จ", "์•„ํŒŒํŠธ", "๋งค๋งค", "10์–ต", "2010๋…„")
house2 = House("๋งˆํฌ", "์˜คํ”ผ์Šคํ…”" , "์ „์„ธ", "5์–ต", "2007๋…„")
house3 = House("์†กํŒŒ", "๋นŒ๋ผ" , "์›”์„ธ", "500/50", "2000๋…„")

houses.append(house1)
houses.append(house2)
houses.append(house3)


print("์ด {0}๋Œ€์˜ ๋งค๋ฌผ์ด ์žˆ์Šต๋‹ˆ๋‹ค.".format(len(houses)))
for house in houses:
house.show_detail()
print("")