๐Ÿ“‚์›น ๊ฐœ๋ฐœ(Web) 48

๋ฌธ์ž์—ด(String)

๋ฌธ์ž์—ด(String) ํ•˜๋‚˜ ์ด์ƒ ์—ฐ์†๋œ ๋ฌธ์ž(character)๋“ค์˜ ๋‚˜์—ด. ํŒŒ์ด์ฌ์—์„œ ๋ฌธ์ž์—ด ํฐ๋”ฐ์˜ดํ‘œ(" ") ๋˜๋Š” ์ž‘์€ ๋”ฐ์˜ดํ‘œ(' ') ์‚ฌ์ด์— ์œ„์น˜. 1. 'hello'์™€ "hello" ๋™์ผ print('hello' == "hello") # ๊ฐ’์ด ๊ฐ™์œผ๋ฉด True ๋ฐ˜ํ™˜ 2. ๋ณ€์ˆ˜์— ๋ฌธ์ž์—ด ํ• ๋‹น a(๋ณ€์ˆ˜) = "Hello"(๋ฌธ์ž์—ด) print(a) 3. ์—ฌ๋Ÿฌ ์ค„ ๋ฌธ์ž์—ด ์„ธ ๊ฐœ์˜ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ณ€์ˆ˜์— ์—ฌ๋Ÿฌ ์ค„ ๋ฌธ์ž์—ด ํ• ๋‹น a = """ํ”ผ์นด์ธ„, ๋ผ์ด์ธ„, ํŒŒ์ด๋ฆฌ, ๊ผฌ๋ถ€๊ธฐ ๋ฒ„ํ„ฐํ”Œ, ์•ผ๋„๋ž€, ํ”ผ์กดํˆฌ, ๋˜๊ฐ€์Šค """ print(a) 4. ๋ฌธ์ž ๋ฐฐ์—ด => ๋ฌธ์ž์—ด ๋ฌธ์ž์—ด ์ธ๋ฑ์‹ฑ(indexing) h e l l o

Python Tuple ์ด์ •๋ฆฌ

ํŠœํ”Œ ๋‹จ์ผ ๋ณ€์ˆ˜์— ์—ฌ๋Ÿฌ ํ•ญ๋ชฉ์„ ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ๋‹ค. ์ˆœ์„œ๊ฐ€ ์žˆ๊ณ , ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๋Š” List ๋‘ฅ๊ทผ ๊ด„ํ˜ธ๋กœ ์ž‘์„ฑ๋œ๋‹ค. 1. ํ˜•์‹ thistuple = ("ํ”ผ์นด์ธ„", "๋ผ์ด์ธ„", "ํŒŒ์ด๋ฆฌ") #ํ•œ ๋ฒˆ ์„ ์–ธํ•˜๋ฉด ๊ฐ’ ๋ณ€๊ฒฝ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ๋ฐ‘์— ํŽธ๋ฒ•์„ ์†Œ๊ฐœํ•  ๊ฑฐ๊ธด ํ•˜์ง€๋งŒ.. print(thistuple) 2. ํŠœํ”Œ ๊ธธ์ด print(len(thistuple)) 3. ํ•ญ๋ชฉ ์ ‘๊ทผ print(thistuple[1]) print(thistuple[-1]) print(thistuple[1:3]) 4. ํŠœํ”Œ๊ฐ’ ๋ณ€๊ฒฝ ๋ฐฉ๋ฒ• (์–ต์ง€๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฒ•) thistuple = ("ํ”ผ์นด์ธ„", "๋ผ์ด์ธ„", "ํŒŒ์ด๋ฆฌ") thiscast = list(thistuple) #casting ๋˜๋Š” ํ˜•๋ณ€ํ™˜ thiscast[1] = "์ž ๋งŒ๋ณด" thistup..

Python List ์ด์ •๋ฆฌ

List ๋‹จ์ผ ๋ณ€์ˆ˜์— ์—ฌ๋Ÿฌ ํ•ญ๋ชฉ์„ ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋œ๋‹ค. List ํ•ญ๋ชฉ์€ ์ˆœ์„œ๊ฐ€ ์ง€์ •๋˜๊ณ  ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•˜๋ฉฐ ์ค‘๋ณต๊ฐ’ ํ—ˆ์šฉ List ์—๋Š” ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์ด ํฌํ•จ๋  ์ˆ˜ ์žˆ๋‹ค. 1. ํ˜•์‹ thislist = ["ํ”ผ์นด์ธ„", "๋ผ์ด์ธ„", "๊ผฌ๋ถ€๊ธฐ"] print(thislist) 2. n๋ฒˆ์งธ ๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ print(thislist[0]) #0๋ฒˆ ์งธ ๊ฐ’ ํ”ผ์นด์ธ„ ๊ฐ€์ง€๊ณ  ์˜ด print(thislist[0][0]) #ํ”ผ์นด์ธ„์˜ 0๋ฒˆ์งธ ๊ฐ’ ํ”ผ 3. List ๊ธธ์ด print(len(thislist)) 4. List ๋ฐ์ดํ„ฐ ์œ ํ˜• List1 = ["ํ”ผ์นด์ธ„", "๋ผ์ด์ธ„", "๊ผฌ๋ถ€๊ธฐ"] List2 = [1, 2, 3, 4, 5] List3 = [True, False, False] #๋‹ค์–‘ํ•œ ์œ ํ˜• ํฌํ•จ ๊ฐ€๋Šฅ List4 = ["abc", 3..

Python ๋‚ด์žฅ ๋ฐ์ดํ„ฐ ์œ ํ˜• ์ •๋ฆฌ

''' ๋‚ด์žฅ ๋ฐ์ดํ„ฐ ์œ ํ˜• Python ๋ณ€์ˆ˜๋Š” ๋‹ค๋ฅธ ์œ ํ˜•์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋‹ค๋ฅธ ์œ ํ˜•์€ ๋‹ค๋ฅธ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ…์ŠคํŠธ ์œ ํ˜• :str ์ˆซ์ž ์œ ํ˜• : int, float, complex ์‹œํ€€์Šค ์œ ํ˜•, list, tuple, range ๋งคํ•‘ ์œ ํ˜• : dict ์„ธํŠธ ์œ ํ˜• : set ๋ถ€์šธ(๋…ผ๋ฆฌ) ์œ ํ˜• : bool ๋ฐ”์ด๋„ˆ๋ฆฌ ์œ ํ˜• : bytes, bytearray ์—†์Œ ์œ ํ˜• : NoneType ''' # str ํ…์ŠคํŠธ ์œ ํ˜• x = "Hello World" print(type(x)) # int ์ •์ˆ˜ x = 20 print(type(x)) #float ์‹ค์ˆ˜ x = 20.5 print(type(x)) # complex ๋ณต์†Œ์ˆ˜ x = 1j x = print(type(x)) #list ๊ฐ’ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ ์‹œํ€€์Šค x..

๋ฐ˜์ง€๋ฆ„์„ ์ „๋‹ฌํ•˜๋ฉด ์›์˜ ๋„“์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” get_area() ํ•จ์ˆ˜

๊ฐœ์š” : ๋ฐ˜์ง€๋ฆ„์„ ์ „๋‹ฌํ•˜๋ฉด ์›์˜ ๋„“์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” get_area() ํ•จ์ˆ˜ import math #math ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด import ํ•ด์คŒ #get_area() ํ•จ์ˆ˜ ์ •์˜ #ํ•จ์ˆ˜๋Š” ์ฝ”๋“œ ๋ฌถ์Œ, ๋ฐ˜๋ณต๋˜๋Š” ๊ฒƒ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด ์“ด๋‹ค. #๊ตฌ์กฐ๋Š” def + ํ•จ์ˆ˜๋ช…(ํ•จ์ˆ˜๊ฐ’=๋งค๊ฐœ๋ณ€์ˆ˜/์ธ์ž) def get_area(radius): """๋ฐ˜์ง€๋ฆ„์„ ์ž…๋ ฅ ๋ฐ›์•„์„œ ์›์˜ ๋„“์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” get_area() ํ•จ์ˆ˜""" #๊ณต์‹ ๋ฌธ์„œ์‹์œผ๋กœ ์“ธ ๋•Œ ๋…์ŠคํŠธ๋ง์œผ๋กœ ์“ฐ๋ฉด ๋œ๋‹ค area = math.pi * math.pow(radius, 2) #math ๋ชจ๋“ˆ์—์„œ pi๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ, math ๋ชจ๋“ˆ์— ์žˆ๋Š” pow ํ•จ์ˆ˜์— radius^2, ์ฆ‰, ์›์˜ ๋„“์ด๋ฅผ ๊ตฌํ•˜๋Š” ๊ณต์‹์ด area๋ผ๋Š” ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅ return area radius = 1..

ํŒŒ์ด์ฌ ์„ค์น˜/์•„๋‚˜์ฝ˜๋‹ค/ํŒŒ์ด์ฐธ/๊นƒ ์„ค์น˜/๊นƒํ—ˆ๋ธŒ ๊ฐ€์ž…

1.ํŒŒ์ด์ฌ ์„ค์น˜ํ•˜๊ธฐ ๊ตฌ๊ธ€์— 'python' ๊ฒ€์ƒ‰ ๋˜๋Š” ๋„ค์ด๋ฒ„์— 'ํŒŒ์ด์ฌ' ๊ฒ€์ƒ‰ https://www.python.org/ Welcome to Python.org The official home of the Python Programming Language www.python.org Downloadsํƒญ ๋ˆ„๋ฅด๊ณ  ์ตœ์‹  ๋ฒ„์ „์˜ ํŒŒ์ด์ฌ์„ ๋‹ค์šด ๋ฐ›๋Š”๋‹ค. ๊ทธ๋ฆฌ๊ณ  Path ์žก์•„์„œ ์„ค์น˜ ๊ทธ๋ฆฌ๊ณ  ์ด๋ ‡๊ฒŒ ์„ค์น˜๋˜์–ด ์žˆ๋Š” IDLE์„ ์‹คํ–‰ํ•˜๋ฉด ํŒŒ์ด์ฌ ์„ค์น˜๋ถ€ํ„ฐ ์‹œ์ž‘๊นŒ์ง€ ์™„๋ฃŒ! Hello World๋ฅผ ์ถœ๋ ฅํ•ด๋ณด์ž! ์ฝ”๋“œ๋Š” print('Hello, World') ๊ฐœ๋ฐœ์ž๋“ค ์‚ฌ์ด์—์„œ Hello World๋ฅผ ์ณ์ค˜์•ผ ์„ฑ๊ณตํ•œ๋‹ค๋Š” ์†Œ๋ฌธ์ด ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. ๋ฏฟ๊ฑฐ๋‚˜ ๋ง๊ฑฐ๋‚˜! 2.์•„๋‚˜์ฝ˜๋‹ค ๊ฐœ๋ฐœ์„ธํŒ…์ด ์ž˜ ๋˜์–ด ์žˆ์–ด์„œ ์“ด๋‹ค. https://www.anacon..

๊ฐœ๋ฐœ์ž ๋˜๊ธฐ ์ฒซ ๊ฑธ์Œ, ์ผ๋‹จ ์–ธ์–ด๋ถ€ํ„ฐ ๋ฐฐ์›Œ๋ณด์ž(๋ถ€์ œ: ํŒŒ์ด์ฌ Python)

๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜๊ณ  ์‹ถ์–ด์„œ ์ผ๋‹จ ๋ฌด์ž‘์ • ํ•™์› ์ƒ๋‹ด๋ถ€ํ„ฐ ๋ฐ›๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค. ๊ณต๋Œ€ ์ถœ์‹ ์ด๊ธฐ๋Š” ํ•˜์ง€๋งŒ ์ฝ”๋”ฉ์€ ์ „๊ณต๊ธฐ์ดˆ๋กœ C++ ๋ฐฐ์›Œ๋ณธ ๊ฒŒ ์ „๋ถ€๋ผ(๊ทธ๊ฒƒ๋„ ๋ฌด๋ ค 7๋…„ ์ „) ์›Œ๋‚™ ์ด ์ชฝ์œผ๋กœ๋Š” ๋ฌธ์™ธํ•œ์ด์—ˆ๋‹ค. ํ”„๋ก ํŠธ์—”๋“œ, ๋ฐฑ์—”๋“œ๊ฐ€ ๋ญ”์ง€ ์•„๋ฌด๊ฒƒ๋„ ๋ชฐ๋ผ์„œ ์ฒ˜์Œ ์ƒ๋‹ด ๊ฐ”๋˜ ๊ณณ ์ƒ๋‹ด์‚ฌ๋ถ„์ด ์ •๋ง ๋‚œ๊ฐํ•ด ํ•˜์…จ๋˜ ๊ฒŒ ๊ธฐ์–ต์— ๋‚จ๋Š”๋‹ค. ๋‚ด๊ฐ€ ์ƒ๋‹ด์„ ๊ฐ”๋˜ ๊ณณ์€ ํ•œ๊ตญICT์ธ์žฌ๊ฐœ๋ฐœ์›, KH์ •๋ณด๊ต์œก์›, ์ค‘์•™์ •๋ณด์ฒ˜๋ฆฌํ•™์›, ์ฝ”๋ฆฌ์•„IT์•„์นด๋ฐ๋ฏธ ์‹ ์ดŒ์ ,๋ฉ”๊ฐ€์Šคํ„ฐ๋””IT ์‹ ์ดŒ์  ๋“ฑ๋“ฑ.. ํ•œ ๊ตฐ๋ฐ ๋” ์žˆ์—ˆ๋˜ ๊ฒƒ ๊ฐ™์€๋ฐ ๊ธฐ์–ต์ด ์•ˆ ๋‚œ๋‹ค. ์•„!! ์œ„์ฝ”๋“œ ๋ถ€ํŠธ์บ ํ”„ ์˜€๋˜ ๊ฒƒ ๊ฐ™๋‹ค. ์—ฌ๊ธฐ์„œ ์œ„์ฝ”๋“œ ๊ฐœ๋ฐœ์ž ์›๋ฐ์ด ํด๋ž˜์Šค๋„ ๋“ค์–ด๋ดค๋‹ค. ๊ต‰์žฅํžˆ ํฅ๋ฏธ๋กญ๊ฒŒ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๊ณ  ๊ฐœ๋ฐœ์ž๊ฐ€ ์–ด๋–ค ์ง์—…์ธ์ง€ ์•Œ ์ˆ˜ ์žˆ๋Š” ๊ธฐํšŒ์˜€์œผ๋‹ˆ ๊ธฐํšŒ๊ฐ€ ์žˆ์œผ๋ฉด ๋“ค์–ด๋ณด๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค. ์•„๋ฌดํŠผ ๋‚˜๋Š” ์˜ค๋ฆฌ๋ฌด์ค‘์˜ ์ƒํƒœ..