목록Language/Python (10)
이것저것
operator 모듈 함수 1. itemgetter() Name_tuples = [ ('olivia', 21,90), ('chris', 24,85), ('jane', 20,88) ] from operator import itemgetter print(sorted(Name_tuples, key = itemgetter(1))) # age 오름차순 정렬 >>> [('jane', 20, 88), ('olivia', 21, 90), ('chris', 24, 85)] 2. attrgetter() class Name: def __init__(self, name, age, score): self.name = name self.age = age self.score = score def printInfo(self): re..
class FourCal: def setdata(self, first, second): self.first = first self.second = second def add(self): result = self.first + self.second return result def mul(self): result = self.first * self.second return result def sub(self): result = self.first - self.second return result def div(self): result = self.first / self.second return result a = FourCal() a.setdata(4,2) print(a.add()) print(a.mul()..
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5P0-h6Ak4DFAUq&categoryId=AV5P0-h6Ak4DFAUq&categoryType=CODE&&& SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com num = int(input()) s = [[0 for col in range(10)] for row in range(10)] # 이차원배열 선언 for i in range(0, num): for j in range(0, i+1): if i==0 or i==j: s[i][j] = 1 else: s[i][j] = ..

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QLkdKAz4DFAUq&categoryId=AV5QLkdKAz4DFAUq&categoryType=CODE SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com list1 = [1,3,5,7,8,10,12] list2 = [4, 6, 9, 11] number = int(input()) year = number // 10000 month = (number % 10000) // 100 day = number % 100 if month in list1: if 1
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QQhbqA4QDFAUq&categoryId=AV5QQhbqA4QDFAUq&categoryType=CODE SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com list = input().split() max = 0 for i in range(0, 10): if int(list[i]) >= max: max = int(list[i]) print(max)
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QQ6qqA40DFAUq&categoryId=AV5QQ6qqA40DFAUq&categoryType=CODE SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com num = int(input()) for i in range(0, num): a,b = input().split() a = int(a) b = int(b) if a < b: print("#%d %s" %(i+1, '')) else: print("#%d %s" %(i+1, '='))
1. input() 와 list()이용 new = input() result = list(new) print(result) >>> 1 2 3 4 >>> ['1', ' ', '2', ' ', '3', ' ', '4'] 2. input(), list(), str() 이용 new = input() result = list(str(new)) print(result) >>> apple >>> ['a', 'p', 'p', 'l', 'e'] 3. input().split()이용 new = input().split() print(new) >>> hi everyone 1 2 3 4 >>> ['hi', 'everyone', '1', '2', '3', '4'] new = input().split(':') print(new)..
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QSEhaA5sDFAUq&categoryId=AV5QSEhaA5sDFAUq&categoryType=CODE&&& SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com num = int(input()) for i in range(0, num): result = 0 list = input().split() for j in range(0, 10): if int(list[j]) % 2 == 1: result += int(list[j]) print("#%d %d" %(i+1, resu..