πŸ“ˆ Increment & πŸ“‰ Decrement

Min-Ho LeeΒ·2020λ…„ 5μ›” 29일
0

Learn Python

λͺ©λ‘ 보기
5/22
post-thumbnail

Friday_May_29
.
.
.

num μ΄λΌλŠ” λ³€μˆ˜μ— 5λ₯Ό 집어 λ„£κ³ ,
1을 μ¦κ°€μ‹œν‚€κ³  μ‹Άλ‹€λ©΄?

num = 5
num = num + 5

μ΄λ ‡κ²Œ 써주면 될 것 이닀.

그런데 μ΄λ ‡κ²Œ ν•΄μ£Όλ©΄ λ³€μˆ˜λ₯Ό 2λ²ˆμ΄λ‚˜ μ¨μ€˜μ•Ό ν•œλ‹€ γ… γ…  πŸ˜₯

κ·Έλž˜μ„œ λ“±μž₯ν•œ λ†ˆμ΄ λ°”λ‘œ μš”λ†ˆ, 두λ‘₯탁!

πŸ“ˆ Increment a Number

증가 μ‹œμΌœμ£ΌλŠ” μ—°μ‚°μžμ΄λ©° μ‚¬μš© 방법은 λ‹€μŒκ³Ό κ°™λ‹€.

πŸ“ˆ μ‚¬μš©λ²•

λ³€μˆ˜μ΄λ¦„ += μ¦κ°€μ‹œν‚¬ κ°’

λ§Œμ•½μ— numμ΄λΌλŠ” λ³€μˆ˜μ— ν˜„μž¬ 5κ°€ λ“€μ–΄μžˆλ‹€κ³  κ°€μ •ν•˜κ³ 
3을 μ¦κ°€μ‹œν‚€κ³  μ‹Άλ‹€λ©΄ πŸ‘‡

num += 3
# num = num + 3 κ³Ό 같은 의미

numμ΄λΌλŠ” λ³€μˆ˜μ˜ 값은 5 + 3, 8이 λœλ‹€.

πŸ“‰ Decrement a Number

κ°μ†Œ μ‹œμΌœμ£ΌλŠ” μ—°μ‚°μžμ΄λ©° μ‚¬μš© 방법은 λ‹€μŒκ³Ό κ°™λ‹€.

πŸ“‰ μ‚¬μš©λ²•

λ³€μˆ˜μ΄λ¦„ -= κ°μ†Œμ‹œν‚¬ κ°’

λ§Œμ•½μ— numμ΄λΌλŠ” λ³€μˆ˜μ— ν˜„μž¬ 5κ°€ λ“€μ–΄μžˆλ‹€κ³  κ°€μ •ν•˜κ³ 
3을 κ°μ†Œμ‹œν‚€κ³  μ‹Άλ‹€λ©΄ πŸ‘‡

num -= 3
# num = num - 3 κ³Ό 같은 의미

numμ΄λΌλŠ” λ³€μˆ˜μ˜ 값은 5 - 3, 2이 λœλ‹€.

profile
πŸ‡ Rabbit can take a rest, but 🐒 turtle can't

0개의 λŒ“κΈ€