본문 바로가기
공부해볼갱/데이터 배워볼갱

[데이터 배워볼갱] 코멘토 청년취업사관학교 전Z전능 데이터 분석가 DAY17

by 갱ㄷ 2025. 1. 15.
🗓️ 2025-01-15(수) 파이썬 기초 3
1. 백준
2. 데이터프레임

 

백준에서 코딩 연습하기

 

백준 : https://www.acmicpc.net/

백준 문제풀이 도우미 : https://solved.ac/

새싹 문제 도전해보기 : https://solved.ac/problems/sprout?category=0

# 10872

n = int(input())
m=1

for i in range(n,1,-1):
    m = m* i
print(m)
# 10950 -1

ab_list = []
iter = int(input())
for i in range(iter) :
    a, b = map(int, input().split())
    ab_list.append(a+b)

for i in range(iter) :
    print(ab_list[i])
# 10950 -2

iter = int(input())
for i in range(iter) :
    a, b = map(int, input().split())
    print(a+b)
# 10871

N, X = map(int, input().split())
y = list(map(int, input().split()))
for i in range(N) :
    if y[i]<X :
        print(y[i], end=' ')
# 10807

count = 0
N = int(input())
x = list(map(int, input().split()))
v = int(input())
for i in range(N) :
    if x[i] == v :
        count += 1
print(count)
# 10951

while True :
    try :
        a, b = map(int, input().split())
        print(a+b)
    except :
        break

 

 

Google Colab Notebook

Run, share, and edit Python notebooks

colab.research.google.com


데이터 프레임 

import seaborn as sns

df = sns.load_dataset('titanic')

import pandas as pd

df = pd.DataFrame({'제품':['사과', '딸기', '수박'],
                   '가격':[3000,9000,21000],
                   '판매량':[24,39,15]})
print(df)

price_av = sum(df['가격']) / len(df['가격'])
sell_av = sum(df['판매량'])/len(df['판매량'])
print(price_av); print(sell_av)

# 'excel_exam.xlsx'
import pandas as pd

df_exam = pd.read_excel('excel_exam.xlsx')
df_exam

df_exam.dtypes

print( sum(df_exam['english'])/len(df_exam['english']) )

print( sum(df_exam['english']/len(df_exam['english'])) )
# 끝자리를 근사치로 계산을 하기에 결과가 달라짐
print( round(sum(df_exam['english']/len(df_exam['english']))) )
# 그래서 소수점 두번째 자리에서 반올림 round 함수
 

Google Colab Notebook

Run, share, and edit Python notebooks

colab.research.google.com