목록2022/01/17 (7)
Developer_Neo
백준 알고리즘 온라인 저지 110998번 : A x B 문제 두 정수 A와 B를 입력받은 다음, A×B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 sys모듈을 사용하고 split를 사용하자 import sys num=sys.stdin.readline() A,B=num.split() print(int(A)*int(B)) input함수이용 A,B=input().split() print(int(A)*int(B))
백준 알고리즘 온라인 저지 1000번 : A-B 문제 두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 sys모듈을 사용하고 split를 사용하자 import sys num=sys.stdin.readline() A,B=num.split() print(int(A)-int(B)) 다른 풀이 input함수이용 A,B=input().split() print(int(A)-int(B))
백준 알고리즘 온라인 저지 1000번 : A+B 문제 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 sys모듈을 사용하고 split를 사용하자 첫번째 시도 import sys print("두 정수를 입력하시오") two_num=sys.stdin.readline() A, B = two_num.split() print(int(A)+int(B)) 두번째 시도 -> 조건이 안들어가서 그런가? 해서 조건을 넣음. import sys print("두 정수를 입력하시오") two_num=sys.stdin.readline() A, B = two_num.split() A, B =..
iterable 객체 - for문과 함께 사용하여 각 데이터를 하나씩 처리할 수 있도록 하는 객체 - 우리가 클래스를 만들때 특정 메소드를 추가 하면코드 상에서 iterable객체로 만들 수 있다. __iter__( ), __next__( ) 함수 2개다 작성해야한다. class collection: def __init__(self, size): self.size = size self.data = list(range(size)) def __iter__(self): self.index = 0 return self def __next__(self): if self.index >= self.size: raise StopIteration # try return n = self.data[self.index] se..
__add__ __mul__ __contains__ __len__ __getitem__ __setitem__ __delitem__ __iter str(문자열) O O O O O list O O O O O O O tuple O O O O O set O O O dict O O O O O O int클래스 __add__(self,other) __sub__(self,other) __mul__(self,other) __truediv__(self,other) __floordiv__(self,other) __mod__(self,other) __pow__(self,other) __gt__(self,other) __ge__(self,other) __it__(self,other) __le__(self,other) __eq_..
클래스 - 객체를 만드는 도구 클래스(class)란 똑같은 무엇인가를 계속해서 만들어 낼 수 있는 설계 도면이고(과자 틀), 객체(object)란 클래스로 만든 피조물(과자 틀을 사용해 만든 과자)을 뜻한다. 출처 https://wikidocs.net/28 05-1 클래스 초보 개발자들에게 클래스(class)는 넘기 힘든 장벽과도 같은 존재이다. 독자들 중에도 클래스라는 단어를 처음 접하는 이들도 있을 것이다. 그러면 도대체 클래스가 무엇인지 ... wikidocs.net 메소드만을 갖는 간단한 클래스 구조 - 메소드를 호출할 때에 self자리에는 인수를 넘기지 않는다. class 클래스명: '''docstring''' def 메소드(self): '''docstring''' 클래스를 만들 때 모든 메소드..
모듈 - 파이썬 코드를 논리적으로 묶어서 관리하고 사용할 수 있도록 하는 것 - 비슷한 종류의 일을 하는 함수들 끼리 따로 묶어놓은 것 - 내장 함수들을 그냥 사용할 수 있지만 모듈안에 있는 함수들은 사용하기전 import를 해줘야한다. 모듈의 종류 표준 모듈 : 파이썬 패키지에 기본적으로 포함된 모듈 (math, datetime) 사용자 정의 모듈 : 사용자가 직접 만들어서 사용하는 모듈 써드파티(third party) 모듈 : 제 3자가 만들어서 제공하는 모듈 (ex 회사) 모듈 사용하기 import 모듈 from 모듈 import 함수or클래스명 import 모듈 as 별명 ''' 모듈에 대해 import를 하게 되면 모듈이름과 함께 사용해야한다. ex) math.pi ''' >>> import m..