์ƒˆ์†Œ์‹

์ธ๊ธฐ ๊ฒ€์ƒ‰์–ด

๐Ÿ“„ Python

2. ์‚ฐ์ˆ ์—ฐ์‚ฐ์ž

  • -
๋ฐ˜์‘ํ˜•
## ์‚ฐ์ˆ  ์—ฐ์‚ฐ์ž
# = : ๋“ฑํ˜ธ ์•„๋‹˜ ์ฃผ์˜, ๋Œ€์ž… ์—ฐ์‚ฐ์ž
# +,-,*,%  //(๋ชซ), %(๋‚˜๋จธ์ง€๊ฐ’), **(์ œ๊ณฑ)

a = 5 ; b = 3 ; c = 2
# ; ์„ธ๋ฏธ ์ฝœ๋ก ์€ ํ•œ์ค„์— ์—ฌ๋Ÿฌ ๋ช…๋ น์–ด ์“ธ ๋•Œ ์‚ฌ์šฉ

print(a+b, a-b, a*b, a/b)
print(a//b, a%b, a**b)

s1, s2, s3 = "100", "100.12", "999999"
print(s1,s2,s3)

print(int(s1), float(s2)+1, int(s3)+1)
# "" ์•ˆ์— ์“ด ์ˆซ์ž๋Š” ๋ฌธ์ž์—ด ์ทจ๊ธ‰
# int, float ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด ์ •์ˆ˜, ์‹ค์ˆ˜๋กœ ํ˜• ๋ณ€ํ™˜

a = 100
b = 123.45
print(str(a)+'1', str(b)+'1')

## ๋Œ€์ž… ์—ฐ์‚ฐ์ž
# +=, -=, *=, /=
a = 10

a += 5 ; print(a)
a -= 5 ; print(a)
a *= 5 ; print(a)
a /= 5 ; print(a)
a //= 5 ; print(a)
a %= 5 ; print(a)
a **= 5 ; print(a)

# ๋™์ „ ๊ตํ™˜ ํ”„๋กœ๊ทธ๋žจ
# ๋ˆ : ์˜ค๋ฐฑ์›, ๋ฐฑ์›, ์˜ค์‹ญ์›, ์‹ญ์›
# ๋ˆ ์ž…๋ ฅ ๋ฐ›์•„

coin = int(input())

c500 = coin / 500
print("์˜ค๋ฐฑ์› %d๊ฐœ" %c500)
coin = coin % 500

c100 = coin / 100
print("๋ฐฑ์› %d๊ฐœ" %c100)
coin = coin % 100

c50 = coin / 50
print("์˜ค์‹ญ์› %d๊ฐœ" %c50)
coin = coin % 50

c10 = coin / 10
print("์‹ญ์› %d๊ฐœ" %c10)


## ๊ด€๊ณ„ ์—ฐ์‚ฐ์ž
## bool
## == : ๋‘ ๊ฐ’์ด ๊ฐ™๋‹ค
## != : ๋‘ ๊ฐ’์ด ๋‹ค๋ฅด๋‹ค
# >, < , >=, <=
a=100; b=200
print(a==b, b!=b)

## ๋…ผ๋ฆฌ ์—ฐ์‚ฐ์ž
# and(๋‘˜๋‹ค ๋งŒ์กฑ), or(๋‘˜ ์ค‘ ํ•˜๋‚˜ ๋งŒ์กฑ), not(๋ฌด์กฐ๊ฑด ๋ฐ˜๋Œ€)

a= 99
print((a>100) and (a<200))
print((a>100) or (a<200))
print(not(a==100))

# ๋น„ํŠธ ์—ฐ์‚ฐ์ž
# & : ๋น„ํŠธ ๋…ผ๋ฆฌ ๊ณฑ
# | : ๋น„ํŠธ ๋…ผ๋ฆฌ ํ•ฉ
# ^ : ๋ฐฐํƒ€์  ๋…ผ๋ฆฌ ํ•ฉ ( xor )
# ~ : ๋น„ํŠธ ๋ถ€์ • ( ๋ฐ˜๋Œ€ ๊ฐ’ )

# << : ์™ผ์ชฝ ์‰ฌํ”„ํŠธ
# >> : ์˜ค๋ฅธ์ชฝ ์‰ฌํ”„ํŠธ

print(12 & 4)
print(1 | 1)
print(1 ^ 1)

a = 10
print(a >> 1)
print(a >> 2)
print(a >> 3)
๋ฐ˜์‘ํ˜•

'๐Ÿ“„ Python' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

6. ๋ฆฌ์ŠคํŠธ ํŠœํ”Œ ๋”•์…”๋„ˆ๋ฆฌ  (0) 2022.06.09
5. while ๋ฐ˜๋ณต๋ฌธ  (0) 2022.06.09
4. for ๋ฐ˜๋ณต๋ฌธ  (0) 2022.06.09
3. if ์กฐ๊ฑด๋ฌธ  (0) 2022.06.09
1. ๋ณ€์ˆ˜  (0) 2022.06.09
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.