본문 바로가기

프로그래밍/Python

(96)
find (a, b) such that am + bn = gcd(m, n) #!/usr/bin/python ######################################### # Programming Challenges ISBN 8979142889 # ---------------------------------------- # problem 51 : Euclid Problem #---------------------------------------- # uva 10104 ######################################### # For given m, n, find a, b such that # am + bn = g ######################################### # Date : 2007.03.31 # Author : DwY..
[PYTHON|SO번역] pip search 실행시에 XMLRPC API is currently disabled due to unmanageable load 에러 발생 https://stackoverflow.com/questions/66375972/getting-error-with-pip-search-and-pip-install Getting error with pip search and pip install hi it is about two days I am getting this error: ERROR: XMLRPC request failed [code:-32500] RuntimeError: PyPI's XMLRPC API is currently disabled due to unmanageable load and will be deprecated in ... stackoverflow.com 패키지를 검색하는 pip search 명령을 실행하면 에러가 발생하고 있다...
ipython : Exception [WinError 995] 스레드 종료 또는 응용 프로그램 요청 때문에 I/O 작업이 취소되었습니다 윈도우 커맨드 프롬프트에서 파이썬 간단한 테스트를 해보기 위해 ipython 을 설치하고, ipython 프롬프트로 들어가서, pd.read_csv 를 수행해 보았는데, 아래와 같은 에러가 발생했다. In [3]: df = pd.read_csv("final_grade.txt") In [4]: df Out[4]: 0 Lee 57 76 65 98 87 86 56 69 61 51 1 Cha 98 55 67 91 61 78 95 98 90 75 2 Kang 79 100 84 53 60 59 93 53 55 75 Unhandled exception in event loop: File "C:\Programs\Python3864\lib\asyncio\proactor_events.py", line 768, in _lo..
[Python|초보] 난수행렬 만들기 n 을 입력받아 0~99 의 난수로 이루어진 n x n 행렬을 반환하기 >>> import numpy as np >>> >>> np.random.randint(0, 100, size=(3, 3)) array([[32, 65, 6], [35, 66, 43], [89, 14, 90]]) >>> np.random.randint(0, 100, size=(2, 2)) array([[87, 7], [22, 97]]) >>> n = int(input()) 4 >>> mat = np.random.randint(0, 100, size=(n, n)) >>> mat array([[53, 62, 9, 84], [62, 22, 75, 72], [86, 68, 43, 14], [97, 59, 20, 84]])
[Python] TypeError: unsupported operand type(s) for 파이썬 초보가 겪을 수 있는 에러입니다. unsupported operand type : 지원되지 않는 피연산자 타입 으로 번역이 됩니다. 파이썬의 기본연산이 불가능한 타입끼리 연산을 하려고 할 때 발생합니다. 예를 들어, 문자열에 숫자를 더하거나 뺄 수는 없을 것입니다. 이럴 때 발생합니다. 예를 몇 개 봅시다. >>> 1 + "3" Traceback (most recent call last): File "", line 1, in 1 + "3" TypeError: unsupported operand type(s) for +: 'int' and 'str' 숫자 1과 문자열 "3"을 더하려 했기 때문에 에러가 발생했습니다. >>> a = input() 3 >>> a '3' >>> 1 + a Tracebac..
카마이클 수 ############################################ # ISBN89-7914-288-9 Programming Challenges # problem 50 : uva 10006 # Carmichael Numbers ############################################ TRUE = 1 FALSE = 0 def pow_mod(a, b, m): '''get the value of a**b mod m''' ret = 1 for i in range(b) : ret = ret*a ret = ret%m return ret def IsPrime(n): if n == 1 : return FALSE i = 2 while i*i
파이썬 xlrd.biffh.XLRDError: Excel xlsx file; not supported 파이썬으로 엑셀파일을 다루는 코드가 아래와 같은 에러메시지를 발생하며 돌아가지 않았다. 에러메시지로 구글링을 하여보니 xlrd 패키지 (엑셀파일 읽기에 사용되는 패키지) 가 이제는 xls 파일 이외의 파일형식( xlsx 같은 )을 지원하지 않는다고 한다. 스택오버플로우에 대응법이 있어서 번역해 놓는다. stackoverflow.com/a/65266270/100093 xlrd.biffh.XLRDError: Excel xlsx file; not supported I am trying to read a macro-enabled Excel worksheet using pandas.read_excel with the xlrd library. It's running fine in local, but when I t..
Connected Component >>> data = [("ㄱ","ㄴ"), ("ㄴ","ㄷ"), ("ㄷ","ㄱ"), ("ㄱ","ㄴ"), ("ㄹ","ㅁ"), ("ㅂ","ㅅ"), ("ㅇ","ㄹ")] >>> data [('ㄱ', 'ㄴ'), ('ㄱ', 'ㄷ'), ('ㄴ', 'ㄷ'), ('ㄹ', 'ㅁ'), ('ㄹ', 'ㅇ'), ('ㅂ', 'ㅅ')] >>> class ConnectedGroups: def __init__(self): self.groups = [] # groups remain mutually exclusive def add(self, e): set_e = set(e) overlap_index = [] for i, g in enumerate(self.groups): if set_e & g: overlap_index.append(i) if..