본문 바로가기

솔루션모음/파워 유저를 위한 파이썬 express 실습문제14

[파워 유저를 위한 파이썬express] 15장 프로그래밍 programming 솔루션 답지 1. import pandas as pd df1 = pd.DataFrame({'item': ['ring0', 'ring0', 'ring1', 'ring1'], 'type': ['Gold', 'Silver', 'Gold', 'Bronze'], 'price': [20000, 10000, 50000, 30000]}) df2 = df1.pivot(index='item', columns='type', values='price') print(df2) 3. >>> df[ ['area', 'population'] ] area population KR 98480 48422644 US 9629091 310232863 JP 377835 127288000 CN 9596960 1330044000 RU 17100000 14070.. 2023. 1. 8.
[파워 유저를 위한 파이썬express] 14장 프로그래밍 programming 솔루션 답지 1. import numpy as np a = np.arange(0,9).reshape((3, 3)) print(a) 3. import numpy as np a = np.random.random((10,10)) amin, amax = a.min(), a.max() print(amin, amax) 5. import numpy as np a = np.zeros((5, 5),dtype=int) a[1::2,::2] = 1 a[::2,1::2] = 1 print(a) 7. import numpy as np x = np.arange(10) print(x) x[(x >= 5) & (x 2023. 1. 8.
[파워 유저를 위한 파이썬express] 12장 프로그래밍 programming 솔루션 답지 1. class Point(object): def __init__(self,x,y): self.x=x self.y=y def __str__(self) : return "(%d, %d)" % (self.x, self.y) class Point3D(Point): def __init__(self,x,y,z): super().__init__(x, y) self.z=z def __str__(self) : return "(%d, %d, %d)" % (self.x, self.y, self.z) my_point=Point3D(1,2,3) print(my_point) 3. import cmath # complex math 모듈 class Function: def __init__(self): pass def value(s.. 2023. 1. 8.
[파워 유저를 위한 파이썬express] 11장 프로그래밍 programming 솔루션 답지 1. count = sum([ 1 for k in range(1, 101) if k%3 == 0]) print(count) 3. subject_marks = [('국어', 88), ('수학', 90), ('영어', 99), ('자연', 82)] print("원래의 리스트:") print(subject_marks) subject_marks.sort(key = lambda x: x[1]) print("\n정렬된 리스트:") print(subject_marks) 5. nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print("원래 리스트:") print(nums) print("세제곱된 값:") cube_nums = list(map(lambda x: x ** 3, nums)) print(.. 2023. 1. 8.