파이썬 -23여름학기(ㄱㅎㅈ)
23 파이썬 기말 족보
elec_cy
2023. 7. 6. 21:21
1.FARM에 관한 CLASS 만들기
2.Farm에 init의 성질(add 등)
3.CSV로 농당 리스트 만들기
4.Gui를 이용해 가축취급 농낭 갯수 계산하는 프로그램 만들기
5.난수생성 iterable class 만들기
Makeup: Gui만들기
import random as rd
class randomgame:
def __init__(self,a,b=0,c=[]):
self._a=int(a)
self._b=b
self._c=c
def __iter__(self):
return self
def __next__(self):
b=rd.randint(1,100)
self._c.append(b)
if len(self._c)<=self._a:
return b
else:
raise StopIteration
a=input('몇개의 난수를 생성할까요?:')
game=randomgame(a)
for x in game:
print(x)