for λ°λ³΅λ¬Έκ³Ό 리μ€νΈ ν¨κ» μ¬μ©νκΈ°
λ°λ³΅λ¬Έμ 리μ€νΈ, νν, λ¬Έμμ΄κ³Ό κ°μ λ°λ³΅ κ°λ₯ν κ°μ²΄
μ μμλ₯Ό μννλ©° λ°λ³΅ μμ
μ μνν©λλ€.
μ΄λ² μμ
μμλ for λ°λ³΅λ¬Έ
μ 리μ€νΈ
μ ν¨κ» μ¬μ©ν΄ 리μ€νΈμ κ° μμλ₯Ό μμ°¨μ μΌλ‘ μ²λ¦¬νλ λ°©λ²μ μμλ³΄κ² μ΅λλ€.
for λ°λ³΅λ¬Έκ³Ό 리μ€νΈμ μ¬μ©
for λ°λ³΅λ¬Έμ 리μ€νΈμ κ° μμμ μ κ·Όνκ³ , μ΄ μμλ€μ νμ©ν΄ λ€μν μ°μ°μ΄λ μμ μ μνν μ μμ΅λλ€.
for λ°λ³΅λ¬Έκ³Ό 리μ€νΈμ μ¬μ©
# μ«μ 리μ€νΈ μμ± numbers = [1, 2, 3, 4, 5] # κ²°κ³Όλ₯Ό μ μ₯ν λΉ λ¦¬μ€νΈ squared_numbers = [] # 'for' λ°λ³΅λ¬Έμ μ¬μ©νμ¬ κ° μ«μμ μ κ³±μ κ³μ°νκ³ κ²°κ³Ό 리μ€νΈμ μΆκ° for number in numbers: # μ κ³± κ³μ° squared = number ** 2 # κ³μ°λ κ°μ 리μ€νΈμ μΆκ° squared_numbers.append(squared) # μλ³Έ 리μ€νΈ [1, 2, 3, 4, 5] print("Original Numbers:", numbers) # μ κ³± κ³μ° κ²°κ³Ό [1, 4, 9, 16, 25] print("Squared Numbers:", squared_numbers)
Mission
0 / 1
for λ°λ³΅λ¬Έμμ μνμ€ λ€μ μ½λ‘ (:)μ μ νμ¬νμ΄λ€.
O
X
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result