[Python Examples] 파이썬 랜덤 예제 코드: np.random.choice()
파이썬 랜덤 예제 코드: np.random.choice() 포스트 난이도: HOO_Junior # Example codes import numpy as np colors = ['black', 'white'] np.random.choice(colors, p=[0.75,0.25], size=10) array(['black', 'black', 'black', 'white', 'black', 'black', 'white', 'black', 'white', 'white'], dtype='
2023. 1. 13.
[Python Examples] pd.DataFrame(): Section별 학생 구분하여 출력하기
pd.DataFrame(): Section별 학생 구분하여 출력하기 포스트 난이도: HOO_Intern # Example Codes import pandas as pd df = pd.DataFrame({"section": [3,1,1,2,2,3], "students": ['James', 'Julia', 'Megan', 'Henry', 'Minji', 'Yelin']}) sec_1 = df[df['section'] == 1] sec_2 = df[df['section'] == 2] sec_3 = df[df['section'] == 3] print(sec_1) print(sec_2) print(sec_3) section students 1 1 Julia 2 1 Megan section students 3 2 ..
2022. 10. 28.
[Python Examples] 파이썬 리스트 예제: 특정 원소 또는 값 찾기
파이썬 리스트 예제: 특정 원소 또는 값 찾기 포스트 난이도: HOO_Intern # Example Code def find_HOO(x): if "HOO" in x: print("HOO is here!") else: print("HOO is not here.") list1 = [15.6,"Wally",54,"Osvaldo"] list2 = ["Wald","HOO",6] list3 = [1,2,3,4,5,6,7,8,"HOO",10,11] print("List1: ") find_HOO(list1) print("List2: ") find_HOO(list2) print("List3: ") find_HOO(list3) List1: HOO is not here. List2: HOO is here! List3: HO..
2022. 10. 7.
[Python Example] print(), print(sep=), print(c1+c2+c3..) 차이점
print(), print(sep=), print(c1+c2+c3..) 차이점 포스트 난이도: HOO_Intern [Notice] 포스트 난이도에 대한 설명 안녕하세요, HOOAI의 Henry입니다. Bro들의 질문에 대한 내용을 우선적으로 포스팅이 되다 보니 각각의 포스트에 대한 난이도가 달라서 난이도에 대한 부분을 작성하면 좋겠다는 의견을 들었습니다 whoishoo.tistory.com # Python Example Codes c1='H' c2='O' c3='O' c4='A' c5='I' print(c1,c2,c3,c4,c5) print(c1,c2,c3,c4,c5,sep='') print(c1+c2+c3+c4+c5) H O O A I HOOAI HOOAI 파이썬(Python)에서 문자열(String)..
2022. 9. 29.
[Python Q&A] Lab session for variables, operators, expressions, basic I/O, and string manipulation
Lab session for variables, operators, expressions, basic I/O, and string manipulation # Exercise 01 print('Sup World?') print(3 + 2 ) print('3 + 2') MyNumber = 3+2.0 MyName = 'Dusty' print(MyName, MyNumber) print('MyName', 'MyNumber') Sup World? 5 3 + 2 Dusty 5.0 MyName MyNumber What is the difference between print(3 + 2) and print('3 + 2') ? 위의 코드에서 3 + 2 를 출력하면 5가 나오지만 '3+2'를 출력하면 3+2가 산출된다. 3..
2022. 9. 20.