본문 바로가기

전체 글1007

[파이썬] 문제 : 연락처 코드 설명 addr = {} # 주소 저장을 위한 빈 딕셔너리 변수 선언 while True: # 문한 반복. 아래 코드에서 break로 빠져 나감 s = int(input('1) 친구 추가 2) 친구 검색 3) 종료 : ')) # 입력 받도 int함수로 정수로 변환 if s == 1: # 입력이 1 이면 name = input('name : ') # 입력 받음 if name in addr: # 입력 받은 이름이 주소록 딕셔너리에 있으면 print('already exists') # 이미 있음 else: # 입력 받은 이름이 주소록 딕셔너리에 없으면 phone = input('phone : ') # 전화번호 입력 받음 addr[name] = phone # 딕셔너리에 추가. 딕셔너리는 딕셔너리명[키] = 값 으로 신.. 2023. 6. 9.
[파이썬] 문제 : 함수 더하기,최대(plus, max) #7 def plus(x, y): return x + y + 1 print(plus(2, 3)) print(plus(5, 7)) #8 def max(x, y): return x if x > y else y # if문을 풀어서 쓸수 있으나 간단한 if문은 이와 같이 사용 가능 print(max(2, 3)) print(max(9, 1)) # 10 no = '10923' name = '홍길동' print(no, name) 2023. 6. 9.
[파이썬] 문제 : 랜덤색 및 크기로 사각형 그리기 import turtle import random t = turtle.Turtle() t.hideturtle() # 거북이 모양 숨기기 # t.shape ("turtle") t.speed(0) # 가장 빠르게 그리기 colors = ['red','blue','yellow','black'] # 조건1 x = [30, 60, 90, 150, 300] # 조건 2 y = [400, 600, 800] # 조건 3 z = [1, 3, 5] # 조건 4 t.pencolor('black') # 조건1, 펜 컬러 black def move(): # 조건5 a = random.randrange(-800, 800) # 랜덤값 선택 b = random.randrange(-800, 800) t.penup() # 펜 들기. 그.. 2023. 6. 7.
[파이썬] SMS(문자메세지) 보내기 (쿨SMS) - 에러(1062) https://console.coolsms.co.kr/ 1) SDK 설치 (패키지) pip install coolsms_python_sdk 2) CoolSMS에 회원가입 3) API 키를 발급 4) Python에서 발신번호를 등록 (기한이 있기 때문에 기한 지나면 재발급) 문자 발송 코드 # pip install coolsms_python_sdk import sys from sdk.api.message import Message from sdk.exceptions import CoolsmsException if __name__ == "__main__": api_key = "xxxxxxxxxx" api_secret = "xxxxxxxxxxxxxxxxxxxxx" params = dict() params['t.. 2023. 6. 6.
[파이썬] 문제 : 문자열을 리스트로 만들기, 리스트를 딕셔너리로 만들기 ss = '가,나,다,라' lst = ss.split(',') # 문자열을 ',' 문자로 분리해서 결과를 리스트로 만듬 print(lst) tmp_lst = ['가,나,다,라','마,바,사,아'] lst = [] # 빈 리스트 타입의 변수선언 for v in tmp_lst: # tmp_lst에서 요소 하나씩 꺼내서 v 에 대입, v는 '가,나,다,라' 그 다음에는 '마,바,사,아' 가 됨 tmp = v.split(',') # 가,나,다,라' 아면 ',' 문자로 분리해서 리스트(tmp)로 만듬 lst.append(tmp) # 분리된 것을 전체 리슽 변수인 lst 에 추가 print(lst) lst = [['가', '나', '다', '라'], ['마', '바', '사', '아']] # 위 문제에서 나온 결과.. 2023. 6. 4.
[파이썬] 문제 : 네이버 KBO 리그 순위 웹크롤링 기록/순위, 야구 : 네이버 스포츠 (naver.com) import requests import pandas as pd import bs4 from pandas.io.json import json_normalize import json url = 'https://sports.news.naver.com/kbaseball/record/index?category=kbo' response = requests.get(url) # print(response.content) # print(response.text) # BeautifulSoup을 사용하여 HTML 파싱 soup = bs4.BeautifulSoup(response.text, 'html.parser') # 표 헤더 데이터 추출 header_row = s.. 2023. 6. 1.
OpenLLaMA GitHub - openlm-research/open_llama: OpenLLaMA, a permissively licensed open source reproduction of Meta AI’s LLaMA 7B trained on the RedPajama dataset GitHub - openlm-research/open_llama: OpenLLaMA, a permissively licensed open source reproduction of Meta AI’s LLaMA 7B trained OpenLLaMA, a permissively licensed open source reproduction of Meta AI’s LLaMA 7B trained on the RedPajama dataset - Gi.. 2023. 6. 1.
대규모 언어 모델 출처 : GitHub - Mooler0410/LLMsPracticalGuide: A curated list of practical guide resources of LLMs (LLMs Tree, Examples, Papers) 2023. 6. 1.
[파이썬] 문제 : 상자 Box 클래스, length, height, depth class Box: def __init__(self,l, h,d): self.__length = l self.__height = h self.__depth = d def getLength(self): return self.__length def getHeight(self): return self.__height def getDepth(self): return self.__depth def setLength(self, l): self.__length = l def setHeight(self, h): self.__height = h def setD(self, d): self.__depth = d def __str__(self): return f"({self.__length}, {self.__height}, .. 2023. 5. 31.
[파이썬] 두 데이터를 같이 shuffle로 섞기 다음과 같이 x, y 데이터가 있을때 shuffle 적용하기 import numpy as np x = np.array([1,2,3,4,5]) # 원래 1번쨰 데이터 y = np.array(['a','b','c','d','e']) # 2번째 데이터 print('x =',x) x_idx = np.arange(x.shape[0]) # x 의 요소수 만큼 인덱스 값을 만듬 print('x_idx =',x_idx) np.random.shuffle(x_idx) # 만들어진 인덱스를 shuffle 함. print('shuffle x_idx =',x_idx) x_new = x[x_idx] # x 데이터를 x_idx로 배치 y_new = y[x_idx] # y 데이터를 x_idx로 배치 print('shuffle x =.. 2023. 5. 30.
728x90
반응형