2.
# 과목별 점수를 나타내는 딕셔너리 생성
scores = {"math": 90, "science": 85, "english": 95}
# 각 과목의 점수 출력
print("math:", scores["math"])
print("science:", scores["science"])
print("English:", scores["english"])
# 또는
for subject, score in scores.items():
print(f"{subject}: {score}")
|
실행결과 |
math: 90 science: 85 english: 95 |