๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ
๐Ÿคท๐Ÿผ‍โ™€๏ธ Etc.../- C, C++, Python, Android

Python์„ ๋ณธ๊ฒฉ์ ์œผ๋กœ ํ•™์Šตํ•˜๊ธฐ ์ „์—

by Wonit 2019. 12. 2.

python์„ ๋ณธ๊ฒฉ์ ์œผ๋กœ ํ•™์Šตํ•˜๊ธฐ ์ „์— ์•Œ์•„์•ผํ•  ์ƒ์‹ ๋ฐ ํŠน์ง•์„ ์ •๋ฆฌํ•ด๋ณด๊ฒ ๋‹ค!

ํ˜„์žฌ ๊ฐ€์žฅ ๋œจ๊ฑฐ์šด ์–ธ์–ด์ธ Python์˜ ๊ธฐ์ดˆ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜์—ฌ Django ๋ฐ ๊ฐ์ข… AI ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ ์šฉ๊นŒ์ง€ ๋‹ค์–‘ํ•œ ๋ถ„์•ผ๋ฅผ ์œ„ํ•œ ํ•™์Šต์ด๋‹ค.
Python์€ ๊ตฌ๊ธ€, ์œ ํŠœ๋ธŒ, ๋“œ๋กญ๋ฐ•์Šค, ๋„ฅํ”Œ๋ฆญ์Šค ๋“ฑ ๋งŽ์€ ํšŒ์‚ฌ๋“ค์ด ์• ์šฉํ•˜๊ณ  ์žˆ๊ณ  ๊ทธ์˜ ์‚ฌ์šฉ ๋ชฉ์ ์— ๋”ฐ๋ผ ๋‹ค์–‘ํ•œ ๋ถ„์•ผ๋ฅผ ๋ง‰๋ก ํ•˜๊ณ  ์‚ฌ์šฉ๋˜๋Š”๋ฐ ๊ทธ ์ด์œ ๋Š” ์•„๋งˆ๋„ ์ƒ์‚ฐ์„ฑ์ด ํฐ ์ด์œ ๊ฐ€ ๋  ๊ฒƒ์ด๋‹ค.

ํŒŒ์ด์ฌ๊ณผ C, Java, C++

์†Œ์ œ๋ชฉ ์ฒ˜๋Ÿผ ํŒŒ์ด์ฌ๊ณผ ๊ฐ๊ธฐ ๋‹ค๋ฅธ ์–ธ์–ด๋“ค ์‚ฌ์ด์—๋Š” ํฐ ํŠน์ง•์ด ์กด์žฌํ•˜๋Š”๋ฐ ๋ฐ”๋กœ ์ธํ„ฐํ”„๋ฆฌํ„ฐ์˜ ์œ ๋ฌด๋กœ ๋‚˜๋‰œ๋‹ค.


๋”์šฑ ์ดํ•ด๊ฐ€ ๋˜๊ธฐ ์‰ฝ๊ฒŒ ๋“ค์—ฌ๋‹ค ๋ณด๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ •์  ์–ธ์–ด์™€ ๋™์  ์–ธ์–ด ์‚ฌ์ด์˜ ์ฐจ์ด์ ์„ ์ดํ•ดํ•ด์•ผ ํ•œ๋‹ค.

์ •์  ์–ธ์–ด

๋™์  ์–ธ์–ด๋ž€ ์ž๋ฃŒ์— ํƒ€์ž…์ด ์ •ํ•ด์ ธ ์ปดํŒŒ์ผ ์‹œ์— ๊ฒฐ์ •์ด ๋˜๋Š” ํŠน์ง•์„ ๊ฐ–๋Š” ์–ธ์–ด๋ฅผ ๋œปํ•œ๋‹ค.

int a = 10;
char b = 'c';
String name = "jang";
int[] a = new int[3];

์ด๋Ÿฌํ•œ ์–ธ์–ด๋“ค์€ ์ปดํŒŒ์ผ ์‹œ์— ์ž๋ฃŒํ˜•์ด ๊ฒฐ์ •๋˜๊ณ  ํ•œ ๋ฒˆ ํƒ€์ž…์ด ์ •ํ•ด์ง€๋ฉด ๋ฐ”๋€Œ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์ปดํŒŒ์ผ๋Ÿฌ์˜ ๋ฌด๋ฆฌ๊ฐ€ ๋œ ๊ฐ€๊ฒŒ ๋˜๋ฉฐ ๊ฒฐ์ •์ ์œผ๋กœ ๋น ๋ฅด๋ฉฐ ํƒ€์ž…์— ๋Œ€ํ•œ ์•ˆ์ „์„ฑ์ด ์žˆ๋‹ค.

๋™์  ์–ธ์–ด

์ •์  ์–ธ์–ด๋Š” ์ปดํŒŒ์ผ ๋„์ค‘์— ์ž๋ฃŒ์˜ ํ˜•์ด ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋Š” ์–ธ์–ด๋ฅผ ๋ง ํ•œ๋‹ค. Python, Ruby, Javascript ๋“ฑ์ด ์žˆ์œผ๋ฉฐ ํ˜„์žฌ ๋Œ€์„ธ๋ฅผ ์ด๋ฃฌ๋‹ค.

var name = "Jang"
name = 10
name = 123
name = "aaa"

์ด์™€ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ์ž๋ฃŒ์˜ ํ˜•์ด ๊ฐ€๋ณ€์ ์ด๋ฏ€๋กœ ํƒ€์ž…์— ๋Œ€ํ•œ ํŠน๋ณ„ํ•œ ์ œ์•ฝ์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. **์ธํ„ฐํ”„๋ฆฌํ„ฐ**๊ฐ€ ์‹คํ–‰ ์‹œ์ ์— ํ•œ ์ค„ ํ•œ ์ค„ ์ฝ”๋“œ๋ฅผ ์ฝ์–ด๋“œ๋ฆฌ๋ฉฐ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์„ ๊ฑฐ์น˜๋ฏ€๋กœ **๋น„๊ต์  ๋Š๋ฆฐ ์†๋„**๋ฅผ ๊ฐ–๊ณ  ์žˆ์ง€๋งŒ ํ˜„์žฌ ์ธํ„ฐํ”„๋ฆฌํ„ฐ ์ตœ์ ํ™”๋ฅผ ํ†ตํ•ด ๋งŽ์ด ํ–ฅ์ƒ๋˜์—ˆ๋‹ค.

์™œ ํŒŒ์ด์ฌ?

ํŒŒ์ด์ฌ์€ ์œ„์™€ ๊ฐ™์ด ๋™์  ์–ธ์–ด์˜ ํŠน์„ฑ์„ ๊ฐ–๊ณ  ์ธํ„ฐํ”„๋ฆฌํ„ฐ์˜ ์—ญํ• ์ด ์กด์žฌํ•˜๋Š”๋ฐ ์™œ ์šฐ๋ฆฌ๋Š” ํŒŒ์ด์ฌ์„ ๋ฐฐ์›Œ์•ผ ํ•˜๊ณ  ์ด๋ ‡๊ฒŒ ํŒŒ์ด์ฌ์ด ์ค‘์š”ํ•œ ์œ„์น˜์— ์™€ ์žˆ๋Š”๊ฐ€? ๋ฅผ ์•Œ์•„๋ณด์ž

๊ฐ€๋…์„ฑ

์ผ๋‹จ ํŒŒ์ด์ฌ์€ ์ธ๊ฐ„์ด ์“ฐ๋Š” ์–ธ์–ด์™€ ๊ฐ€์žฅ ์œ ์‚ฌํ•˜๋‹ค.

if 4 in [1,2,3,4]: print("4๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค")

๋งŒ์•ฝ 4๊ฐ€ [1,2,3,4] ์•ˆ์— ์กด์žฌํ•˜๋ฉด 4๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋‚ด์šฉ์ด๋‹ค.

์œ„์™€ ๊ฐ™์ด ์ธ๊ฐ„์ด ์‰ฝ๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” ์–ธ์–ด์ธ๋ฐ ์ด ๋ง์€ ๊ณง ์ธ๊ฐ„์ด ๋ฐฐ์šฐ๊ธฐ ์‰ฝ๋‹ค๋Š” ํŠน์ง•์„ ๊ฐ–๊ณ  ์žˆ๋‹ค


๋˜ํ•œ ํŒŒ์ด์ฌ์€ **์ค‘๊ด„ํ˜ธ์˜ ์—ญํ• ์„ ๋“ค์—ฌ์“ฐ๊ธฐ๊ฐ€ ์ˆ˜ํ–‰ํ•œ๋‹ค.**
void method(){
    if(){
        while(){
            statements;
        }
    }
}

์ค‘๊ด„ํ˜ธ๊ฐ€ ๋„ˆ๋ฌด ๋ณด๊ธฐ ๋ถˆํŽธํ•˜์ง€ ์•Š์€๊ฐ€..? ์ด๋Ÿฌํ•œ ๋‹จ์ ๋“ค์„ ํŒŒ์ด์ฌ์€

def solve 
    if(): while

์ด๋Ÿฌํ•œ ๋ฐฉ์‹์œผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์žฅ์ ์ด ์žˆ๋‹ค.

ํŒŒ์ด์ฌ์„ ์‚ฌ์šฉํ•˜์ง€ ๋ง์•„๋ผ

์ด๋Ÿฌํ•œ ์žฅ์ ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ๋ชจ๋“  ์ƒํ™ฉ์—์„œ ํŒŒ์ด์ฌ์ด ๋ฐ˜๊ฐ€์šด ์–ธ์–ด์ž„์ด ์•„๋‹Œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค.

ํ”„๋กœ๊ทธ๋žจ์ด ๊ณ„์‚ฐ ์ž‘์—…์„ ๋งŽ์ด ํ•˜๋Š” ๊ฒฝ์šฐ

์ด๋Ÿฌํ•œ ๊ฒฝ์šฐ๋Š” ํŒŒ์ด์ฌ ๋ณด๋‹ค ๋‹ค๋ฅธ ์ปดํŒŒ์ผ ์–ธ์–ด๊ฐ€ ํšจ๊ณผ์ ์ผ ์ˆ˜ ์žˆ๋‹ค.




์ด์ œ ํŒŒ์ด์ฌ ํ•™์Šต์„ ์œ„ํ•œ ๋ฐฐ๊ฒฝ์ง€์‹์„ ์กฐ๊ธˆ ๊ฐ–์ท„๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ๋‹ค์Œ ๊ฐ•์˜๋ถ€ํ„ฐ ํŒŒ์ด์ฌ์— ๋Œ€ํ•œ ํ•™์Šต์„ ์‹œ์ž‘ํ•ด๋ณด์ž.

๋Œ“๊ธ€