accumulate

    [Python | week1-1] Hash ์ž๋ฃŒ๊ตฌ์กฐ | accumulate ํ•จ์ˆ˜ | enumerate ํ•จ์ˆ˜ | counter ํ•จ์ˆ˜

    week1-1 ํ•™์Šต ๋‚ด์šฉ 1. [์ž๋ฃŒ๊ตฌ์กฐ] Hash 2. enumerate ํ•จ์ˆ˜ 3. accumalate ํ•จ์ˆ˜ 4. counter ํ•จ์ˆ˜ 1. [์ž๋ฃŒ๊ตฌ์กฐ] Hash Python์—์„œ Hash ์ž๋ฃŒ๊ตฌ์กฐ๋Š” ๋”•์…”๋„ˆ๋ฆฌ(Dictionary)๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. ๋”•์…”๋„ˆ๋ฆฌ๋Š” key-value๊ฐ’์„ ์Œ์œผ๋กœ ๊ฐ–๋Š”๋‹ค. key๊ฐ’์€ ์ž๋ฃŒํ˜•์ด ๋‹ฌ๋ผ๋„ ๊ณต์กดํ•  ์ˆ˜ ์žˆ๋‹ค. key๊ฐ’๋งŒ ์•Œ๊ณ  ์žˆ๋‹ค๋ฉด ์–ธ์ œ๋“ ์ง€ value์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค. ๋‹ค์Œ ์ˆœ์„œ๋กœ ์ž์„ธํžˆ ์•Œ์•„๋ณด์ž - ์กฐํšŒ - ์ž…๋ ฅ - ์‚ญ์ œ 1) get ํ•จ์ˆ˜ dic = {"BTS": "๋ฐฉํƒ„์†Œ๋…„๋‹จ", "๋น„๋ฐ€๋ฒˆํ˜ธ": 4313} print(dic.get("๋น„๋ฐ€๋ฒˆํ˜ธ")) #4313 2) [] dic = {"BTS": "๋ฐฉํƒ„์†Œ๋…„๋‹จ", "๋น„๋ฐ€๋ฒˆํ˜ธ": 4313} print(dic["๋ฐฉํƒ„์†Œ๋…„๋‹จ"]) #{"..