Quiz) 주어진 코드를 활용하여 부동산 프로그램을 작성하시오.
(출력 예제)
총 3대의 매물이 있습니다.
강남 아파트 매매 10억 2010년
마포 오피스텔 전세 5억 2007년
송파 빌라 월세 500/50 2000년
내가 작성한 코드
class House:
# 매물 초기화 : 위치, 건물 종류, 매물 종류, 가격, 준공년도
def __init__(self, location, house_type, deal_type, price, completion_year):
self.location = location
self.house_type = house_type
self.deal_type = deal_type
self.price = price
self.completion_year = completion_year
# 매물 정보 표시
def show_detail(self):
print(
f"{self.location} {self.house_type} {self.deal_type} {self.price} {self.completion_year}")
houses = [House("강남", "아파트", "매매", "10억", "2010년"),
House("마포", "오피스텔", "전세", "5억", "2007년"),
House("송파", "빌라", "월세", "500/50", "2000년")]
print("총 {0}대의 매물이 있습니다.".format(len(houses)))
for h in houses:
h.show_detail()
출처 - 나도코딩
'코딩테스트' 카테고리의 다른 글
간단 퀴즈 - 택시 승객 시간별 매칭 (0) | 2023.03.25 |
---|---|
코딩 퀴즈 - 치킨집 자동 주문 시스템 (0) | 2023.03.23 |
프로그래머스 - 모의고사(수포자) (0) | 2023.03.22 |
간단 코딩 퀴즈 - 표준 체중 구하는 프로그램 작성 (0) | 2023.03.22 |
간단 퀴즈 - 치킨 커피 추첨 (0) | 2023.03.21 |