본문 바로가기
반응형
python 별찍기 (다이아몬드) # 값 입력받기 size = int(input("please input size")) # size = 5 #다이아몬드 상체 for x in range(1, size * 2, 2): print(("x" * ( (size * 2 - 1 - x) // 2 )) + ("O" * x) + ("x" * ( (size * 2 - 1 - x) // 2 ))) #다이아몬드 하체 for y in range(size * 2-3, 0, -2): print(("x" * ( (size * 2 - 1 - y) // 2 )) + "O" * y + ("x" * ( (size * 2 - 1 - y) // 2 ))) 2020. 3. 18.
벅스 일간차트 크롤링 from urllib.request import urlopen from bs4 import BeautifulSoup from html2text import html2text import sys import pprint if __name__ == "__main__": f = open("bugs_chart.txt", "w") url = urlopen("http://music.bugs.co.kr/chart/track/day/total") bs = BeautifulSoup(url,'html.parser') artist_list=[] # 가수 리스트 생성 title_list = [] # 제목 리스트 생성 daily_chart = {} # 가수 + 제목 딕셔너리 artist = bs.find_all('p', cla.. 2020. 2. 8.
별찍기(직각삼각형) size = int(input("please input size")) for i in range(size): print("*"*i) size = int(input("please input size")) for i in range(size,0,-1): print("*"*i) 2020. 2. 8.
별찍기(정사각형) star_string = " * " size = int(input("please input size")) for i in range(size): print(star_string *size) 2020. 2. 8.
숫자야구 게임 import random print("야구게임을 시작합니다 !!!\n--------------------------") i = random.randint(1,9) j = random.randint(1,9) k = random.randint(1,9) result = [str(i),str(j),str(k)] # 야구게임 정답 print('답: ',result) # 확인용 지울거얌 answer = [] strike_count = 0 ball_count = 0 try_count = 0 while(strike_count 2020. 2. 8.
로또 번호 생성기 import random lotto = [] game = int(input("lotto 게임 수를 입력하세요:")) print("===============================") for m in range(1,game+1): for a in range(1,8): i = random.randrange(1,46) lotto.append(i) lotto = list(set(lotto)) bonus = random.randint(1,46) lotto.sort() #리스트 정렬 for overlap in range(0,3): if (len(lotto) != 7): last = random.randint(1, 46) lotto.append(last) print(lotto,'+',lotto.pop()) l.. 2020. 2. 8.
구구단 게임 import random import time import numpy as np import sys def check(x): #정답 체크 global correct_count if(x == int(result)): print("정답!! :",str(result)) correct_count = correct_count + 1 elif( int(x) != int(result)): print("오답!! :",str(result)) # correct_count = correct_count - 1 else: print("뭐야??") def question(a): #문제 생성하기 global result b = random.randint(2, 4) numbers = [random.randint(2, 12) for .. 2020. 2. 8.
반응형