
greeting = "hello, pyhton"
age = 42
print(greeting)
parint(age)
답 >
Hello, Python
42
다음 코드는 리스트에서 특정 요소를 가져오는 문제입니다.
#빈칸에 들어갈 코드를 완성하세요!
fruits = ["apple", "banana", "cherry"]
print(fruits[___]) # 리스트에서 "banana" 출력
파이썬은 시작이 0, 마지막이 -1 이기때문에
바나나는 1 또는 -2
다음 코드는 딕셔너리에서 값을 가져오는 예제입니다.
빈칸에 들어갈 코드를 완성하세요.
student = {"name": "Alice", "age": 20}
print(student[ ]) # "Alice" 출력
답 > 여기는 딕셔너리이기때문에 key값(name)과 value값(alice)로 나뉜다.
1. 엘리스는 name이란 키값의 value 이기때문에 "name" 입력
x = 10
if x > 5:
print("x is greater than 5")
elif:
print("x is smaller than 5")
else:
print("x is equal to 5")
답 : x is greater than 5

즉 if 다음 " 첫번째 경우가 아니라면~" = elif
else는 위 두개도 아니라면~ 즉 마지막 사용
colors = ["red", "green", "blue"]
for color in colors:
print(color)
답 :
red
green
blue
for 뒤에는 clors 안에 담긴 리스트들을 반복문으로 하나씩 꺼내오는 것임
따라서 color, item, i(숫자) ,x(요소) 등 으로 아무거나 가능하지만 중요한건 colors라는 리스트에 담긴 요소를 추출하는 for 반복문이라고 생각하면된다.

예시 데이터
numbers = [10, 20, 30, 40, 50]
직접 평균 계산
total = sum(numbers)
# 여기에 코드를 작성하세요
total_avg = total / len(___)
print("평균 CPC:", total_avg)
답 > len(numbers)
결과 :