Algorithm/ํ๋ก๊ทธ๋๋จธ์ค
์ท๊ฐ๊ฒ ํ ์ธ ๋ฐ๊ธฐ / ๋์ ๋๋ฆฌ(Dictionary) ์๋ฃํ ํ์ฉํ๊ธฐ
hello_u
2022. 12. 28. 20:21
๋จธ์ฑ์ด๋ค ์ท๊ฐ๊ฒ๋ 10๋ง ์ ์ด์ ์ฌ๋ฉด 5%, 30๋ง ์ ์ด์ ์ฌ๋ฉด 10%, 50๋ง ์ ์ด์ ์ฌ๋ฉด 20%๋ฅผ ํ ์ธํด์ค๋๋ค.
๊ตฌ๋งคํ ์ท์ ๊ฐ๊ฒฉ price๊ฐ ์ฃผ์ด์ง ๋, ์ง๋ถํด์ผ ํ ๊ธ์ก์ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด๋ณด์ธ์.
์ ํ์ฌํญ
10 โค price โค 1,000,000
price๋ 10์ ๋จ์๋ก(1์ ์๋ฆฌ๊ฐ 0) ์ฃผ์ด์ง๋๋ค.
์์์ ์ดํ๋ฅผ ๋ฒ๋ฆฐ ์ ์๋ฅผ returnํฉ๋๋ค.

๋์
๋๋ฆฌ๋ Key์ Value๋ฅผ ํ ์์ผ๋ก ๊ฐ๋ ์๋ฃํ
Key, Value ์ ์ป๊ธฐ(items)
>>> a.items()
dict_items([('name', 'pey'), ('phone', '010-9999-1234'), ('birth', '1118')])
items ํจ์๋ Key์ Value์ ์์ ํํ๋ก ๋ฌถ์ ๊ฐ์ dict_items ๊ฐ์ฒด๋ก ๋๋ ค์ค๋ค.