ETC/Python(5)
-
[Python] 아스키코드 변경
ord() 아스키코드로 변환해주는 함수 A = input() print(ord(A)) 파이썬 칭찬해
2022.08.08 -
[Python] 사칙연산
더하기 / 빼기 / 곱하기 / 나누기 / 몫구하기 / 나머지구하기 A, B = map(int, input().split()) print(A+B) print(A-B) print(A*B) print(A//B) print(A%B) 나누기는 소수점까지 쭉 계속 다 나옴
2022.08.08 -
[스터디] Python -순열(permutations), 조합(combinations)
순열(permutations) n개 중에서 r개를 고르는 것 (중복O) from itertools import permutations v = [0, 1, 2, 3] for combi in permutations(v, 2): print(combi) 조합(combinations) n개 중에서 순서에 상관없이 r개를 고르는 것 (중복X) from itertools import combinations v = [0, 1, 2, 3] for combi in combinations(v, 2): print(combi)
2022.08.03 -
[스터디] Python -반복문
기본적인 반복문, 인덱스번호 출력 list = list(map(int, input().split())) for i in range(0, len(list)) : print(i) 배열의 아이템 출력 list = list(map(int, input().split())) for item in list : print(item)
2022.08.03 -
[Python] 입출력(input/print), 배열정렬(sort)
기본 입력 -input() split()을 사용하여 띄어쓰기 단위로 나누기 (나누고 싶은 단위를 설정할 수 있음) 정렬 -sort() 기본은 오름차순 내림차순은 sort의 매개변수로 reverse=True 입력 list = list(map(int, input().split())) list.sort() print(list) list.sort(reverse=False) print(list) list.sort(reverse=True) print(list)
2022.08.03