728x90
반응형
11. 파이썬 클래스 / 261 ~ 270
# 파이썬 300제 _ 261번
# class Stock:
# pass
# 파이썬 300제 _ 262번
# class Stock:
# def __init__(self, name, code):
# self.name = name
# self.code = code
# samsung = Stock("삼성전자", "005930")
# print(samsung.name)
# print(samsung.code)
# 파이썬 300제 _ 263번
# class Stock:
# def __init__(self, name, code):
# self.name = name
# self.code = code
# def set_name(self, name):
# self.name = name
# a = Stock(None, None)
# a.set_name("삼성전자")
# print(a.name)
# 파이썬 300제 _ 264번
# class Stock:
# def __init__(self, name, code):
# self.name = name
# self.code = code
# def set_name(self, name):
# self.name = name
# def set_code(self, code):
# self.code = code
# a = Stock(None, None)
# a.set_code("005930")
# print(a.code)
# 파이썬 300제 _ 265번
# class Stock:
# def __init__(self, name, code):
# self.name = name
# self.code = code
# def set_name(self, name):
# self.name = name
# def set_code(self, code):
# self.code = code
# def get_name(self):
# return self.name
# def get_code(self):
# return self.code
# samsung = Stock("삼성전자", "005930")
# print(samsung.get_name())
# print(samsung.get_code())
# 파이썬 300제 _ 266번
# class Stock:
# def __init__(self, name, code, per, pbr, pay):
# self.name = name
# self.code = code
# self.per = per
# self.pbr = pbr
# self.pay = pay
# def set_name(self, name):
# self.name = name
# def set_code(self, code):
# self.code = code
# def get_name(self):
# return self.name
# def get_code(self):
# return self.code
# 파이썬 300제 _ 267번
# class Stock:
# def __init__(self, name, code, per, pbr, dividend):
# self.name = name
# self.code = code
# self.per = per
# self.pbr = pbr
# self.dividend = dividend
# def set_name(self, name):
# self.name = name
# def set_code(self, code):
# self.code = code
# def get_name(self):
# return self.name
# def get_code(self):
# return self.code
# a = Stock("삼성전자", "005930", 15.79, 1.33, 2.83)
# print(a.dividend)
# 파이썬 300제 _ 268번, 269번
# class Stock:
# def __init__(self, name, code, per, pbr, dividend):
# self.name = name
# self.code = code
# self.per = per
# self.pbr = pbr
# self.dividend = dividend
# def set_name(self, name):
# self.name = name
# def set_code(self, code):
# self.code = code
# def set_per(self, per):
# self.per = per
# def set_pbr(self, pbr):
# self.pbr = pbr
# def set_dividend(self, dividend):
# self.dividend = dividend
# def get_name(self):
# return self.name
# def get_code(self):
# return self.code
# a = Stock("삼성전자", "005930", 15.79, 1.33, 2.83)
# a.set_per(12.75)
# print(a.per)
# 파이썬 300제 _ 270번
# class Stock:
# def __init__(self, name, code, per, pbr, dividend):
# self.name = name
# self.code = code
# self.per = per
# self.pbr = pbr
# self.dividend = dividend
# def set_name(self, name):
# self.name = name
# def set_code(self, code):
# self.code = code
# def set_per(self, per):
# self.per = per
# def set_pbr(self, pbr):
# self.pbr = pbr
# def set_dividend(self, dividend):
# self.dividend = dividend
# def get_name(self):
# return self.name
# def get_code(self):
# return self.code
# stock_list = []
# samsung = Stock("삼성전자", "005930", 15.79, 1.33, 2.83)
# hyundai = Stock("현대차", "005380", 8.70, 0.35, 4.27)
# lg = Stock("LG전자", "066570", 317.34, 0.69, 1.37)
# stock_list.append(samsung)
# stock_list.append(hyundai)
# stock_list.append(lg)
# for i in stock_list:
# print(i.code, i.per)
728x90
반응형
'Python' 카테고리의 다른 글
초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 281 ~ 290 (0) | 2020.10.06 |
---|---|
초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 271 ~ 280 (0) | 2020.09.22 |
초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 251 ~ 260 (0) | 2020.09.16 |
초보자를 위한 파이썬 300제 / 10. 파이썬 모듈 / 241 ~ 250 (0) | 2020.09.14 |
초보자를 위한 파이썬 300제 / 09. 파이썬 함수 / 221 ~ 240 (0) | 2020.09.10 |