[Python] math ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
ยท
๐Ÿ“Language/โž• Python
math ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉํ•˜๊ธฐ import matha = 4b = 5c = 1.6# ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜ ๊ตฌํ•˜๊ธฐ => 1gcd = math.gcd(a, b)# ์ตœ์†Œ ๊ณต๋ฐฐ์ˆ˜ ๊ตฌํ•˜๊ธฐ => 20(a * b) // math.gcd(a, b) # python 3.8 ๋ฒ„์ „ ์ดํ•˜math.lcm(a, b) # python 3.9 ๋ฒ„์ „ ์ด์ƒ# ์ œ๊ณฑ๊ทผ ๊ตฌํ•˜๊ธฐmath.sprt(a)# ์†Œ์ˆ˜ ์˜ฌ๋ฆผํ•ด์„œ ์ •์ˆ˜ ๊ตฌํ•˜๊ธฐ => 2math.ceil(c)# ์†Œ์ˆ˜ ๋ฒ„๋ฆผํ•ด์„œ ์ •์ˆ˜ ๊ตฌํ•˜๊ธฐ => 1math.floor(c)
[Python] ๋”•์…”๋„ˆ๋ฆฌ
ยท
๐Ÿ“Language/โž• Python
๋”•์…”๋„ˆ๋ฆฌ : ํ‚ค-๊ฐ’ ์Œ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ์ž๋ฃŒํ˜•dict = {key1:value1, key2: value2} person = { "name": "Alice", "age": 30, "city": "New York"}# ๊ฐ’ ์ถœ๋ ฅ => "Alice"print(person["name"])# ๊ฐ’ ๋ณ€๊ฒฝperson["age"] = 25# ๊ฐ’ ์ถ”๊ฐ€person["email"] = "alice@gmail.com"# ๊ฐ’ ์‚ญ์ œdel person["email"]# key ์กด์žฌ ์—ฌ๋ถ€ ํ™•์ธif "name" in person: print("์กด์žฌํ•จ") ๋ฉ”์„œ๋“œperson = { "name": "Alice", "age": 30, "city": "New York"}# key๋กœ ๊ฐ’ ์กฐํšŒ, ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ..
[Python] set
ยท
๐Ÿ“Language/โž• Python
set : ์ง‘ํ•ฉ- ์š”์†Œ๊ฐ€ ์ค‘๋ณต๋˜์ง€ ์•Š๋Š”๋‹ค. (์ค‘๋ณต ์ œ๊ฑฐ)- ์š”์†Œ์˜ ์ˆœ์„œ๋Š” ๋ณด์žฅ๋˜์ง€ ์•Š๋Š”๋‹ค. arr1 = [1,2,3]# ์ง‘ํ•ฉ์œผ๋กœ ์ƒ์„ฑ => {1,2,3}s = set(arr1)# ์š”์†Œ ์ถ”๊ฐ€ => {1,2,3,4}s.add(4)# ์š”์†Œ ์ œ๊ฑฐ => {1,2,3}s.remove(4) # ์š”์†Œ๊ฐ€ ์—†์œผ๋ฉด ์—๋Ÿฌ ๋ฐœ์ƒs.discard(4) #์š”์†Œ๊ฐ€ ์—†์–ด๋„ ์—๋Ÿฌ ๋ฐœ์ƒ X s1 = {1,2,3}s2 = {2,4,6}# ํ•ฉ์ง‘ํ•ฉ => {1,2,3,4,6}print(s1 | s2)# ๊ต์ง‘ํ•ฉ => {2}print(s1 & s2)# ์ฐจ์ง‘ํ•ฉ => {1,3}print(s1 - s2)
[Python] list
ยท
๐Ÿ“Language/โž• Python
arr1 = [1,2,5,4,3]# ๋ฐฐ์—ด์—์„œ ๊ฐ’ ๋ฝ‘๊ธฐ => 4arr1[3]arr1[-2]# ๋ฐฐ์—ด์—์„œ ๊ฐ’์˜ index ๊ตฌํ•˜๊ธฐ => 3arr1.index(4)# ๋ฐฐ์—ด ๊ธธ์ด ๊ตฌํ•˜๊ธฐ => 5len(arr1)# ๋ฐฐ์—ด ์ตœ๋Œ€๊ฐ’ ๊ตฌํ•˜๊ธฐ => 5max(arr1)# ๋ฐฐ์—ด ํ•ฉ๊ณ„ ๊ตฌํ•˜๊ธฐ => 15sum(arr1)# ๋ฌธ์ž์—ด๋กœ ์ถœ๋ ฅ => '12543'''.join(arr1)  ๋ณ€๊ฒฝarr1 = [1,2,3]# ๊ฐ’ ์ถ”๊ฐ€ => [1,2,3,4]arr1.append(4)# ํŠน์ • ์ธ๋ฑ์Šค์— ๊ฐ’ ์ถ”๊ฐ€ => [1,4,2,3]arr1.insert(4, 1)# ํŠน์ • ๊ฐ’ ์‚ญ์ œ => [1,2]arr1.remove(3)  ์ •๋ ฌarr1 = [1,2,5,4,3]# ๋ฐฐ์—ด ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ => [1,2,3,4,5]arr1.sort()# ๋ฐฐ์—ด ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ =>..
[Python] ์ •์ˆ˜
ยท
๐Ÿ“Language/โž• Python
num1 = 5num2 = 8# ์ •์ˆ˜๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ => '5'str(num1)# 0 ๋ถ€ํ„ฐ ์ฃผ์–ด์ง„ ์ˆซ์ž๊นŒ์ง€ ์ˆซ์ž ์ƒ์„ฑ => range(0, 5)range(5)# list๋กœ ๋‚˜์—ด => [0, 1, 2, 3, 4]list(range(5))# ๊ฐ€์žฅ ํฐ ์ˆ˜ ์ฐพ๊ธฐ => 8max(num1, num2)# ๋‚˜๋ˆ„๊ธฐ(๋ชซ์„ ์ •์ˆ˜๋งŒ ๋‚จ๊ธฐ๊ธฐ) => 28//3# ์ œ๊ณฑ ๊ตฌํ•˜๊ธฐ => 273**3# ์ œ๊ณฑ๊ทผ ๊ตฌํ•˜๊ธฐ => 39**0.5  ํƒ€์ž… ๋ณ€ํ™˜num1 = 123# ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ => '123'str(num1)# ๋ฐฐ์—ด๋กœ ๋ณ€ํ™˜1 => [1,2,3][int(i) for i in str(num1)]
[Python] ๋ฌธ์ž์—ด
ยท
๐Ÿ“Language/โž• Python
inputstr1 = input() ๋ฌธ์ž์—ด๋ณ€ํ˜•str1 = 'Hello'str2 = ' Python'# ํ•ฉ์น˜๊ธฐ => 'Hello Python'str1 + str2# ๊ธธ์ด ๊ตฌํ•˜๊ธฐ => 5len(str1)# ์•ž๋’ค ๊ณต๋ฐฑ ์ œ๊ฑฐํ•˜๊ธฐ => 'Python'str2.strip()# ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜ => 'HELLO'st1.upper()# ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ => 'hello'str1.lower()# ๋Œ€์†Œ๋ฌธ์ž ์„œ๋กœ ๋Œ€์น˜ ๋ณ€ํ™˜ => 'hELLO'strq.swapcase()  ํƒ€์ž… ๋ณ€ํ™˜str1 = 'Hello Python'str2 = '100'arr = ['Hello', 'Python']# ์ •์ˆ˜๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ => 100int(str2)# list๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ (๊ณต๋ฐฑ๊ธฐ์ค€) => ['Hello', 'Python']str1.split(' '..
๋ธŒ๋ผ์šฐ์ € ๋ Œ๋”๋ง ๊ณผ์ • ์ดํ•ดํ•˜๊ธฐ (์ž‘์„ฑ์ค‘)
ยท
๐Ÿ“Language/๐ŸŸจ Javascript
javascript๋ฅผ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ๋‚ด๊ฐ€ ์•„์ง ๋ธŒ๋ผ์šฐ์ € ๋ Œ๋”๋ง ๊ณผ์ •์— ๋Œ€ํ•ด ์ •ํ™•ํžˆ ์•Œ์ง€ ๋ชปํ•˜๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๊นจ๋‹ฌ์•„์„œ ์ •๋ฆฌํ•ด๋ณด๊ธฐ๋กœํ–ˆ๋‹ค. ์‚ฌ์ „์ง€์‹ ๋ธŒ๋ผ์šฐ์ € : ์›น์ƒ์— ์กด์žฌํ•˜๋Š” ํŽ˜์ด์ง€๋“ค์„ ๊ฒ€์ƒ‰ ๋ฐ ์—ด๋žŒํ•˜๊ธฐ ์œ„ํ•œ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์˜ ์ด์นญ ex) chorme, safari, internet explorer, microsoft edge ๋“ฑ ๋ Œ๋”๋ง : HTML, CSS, JS๋กœ ์ž‘์„ฑ๋œ ๋ฌธ์„œ๋ฅผ ํŒŒ์‹ฑํ•˜์—ฌ ๋ธŒ๋ผ์šฐ์ €์— ์‹œ๊ฐ์ ์œผ๋กœ ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ ํŒŒ์‹ฑ : ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋กœ ์ž‘์„ฑ๋œ ๋ฌธ์„œ์˜ ๋ฌธ์ž์—ด์„ 'ํ† ํฐ'์œผ๋กœ ๋ถ„ํ•ด -> ํ† ํฐ์œผ๋กœ ํŠธ๋ฆฌ๊ตฌ์กฐ์˜ ์ž๋ฃŒ๊ตฌ์กฐ์ธ 'ํŒŒ์ŠคํŠธ๋ฆฌ'๋ฅผ ์ƒ์„ฑ -> ํŒŒ์ŠคํŠธ๋ฆฌ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ '๋ฐ”์ดํŠธ ์ฝ”๋“œ' ์ƒ์„ฑํ•˜๊ณ  ์‹คํ–‰ ๋ธŒ๋ผ์šฐ์ € ๋ Œ๋”๋ง ๋™์ž‘ ๊ณผ์ • ๋ Œ๋”๋ง์— ํ•„์š”ํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ์„œ๋ฒ„์— ์š”์ฒญํ•˜๊ณ  ์‘๋‹ต ๋ฐ›๋Š”๋‹ค. ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ์‘๋‹ต๋œ ๋ฆฌ์†Œ์Šค๋ฅผ ํŒŒ์‹ฑํ•˜..
[JS] ๋ณ€์ˆ˜ ์„ ์–ธ var, let, const
ยท
๐Ÿ“Language/๐ŸŸจ Javascript
Javascript๋Š” ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ• ๋•Œ ์ œ์ผ ์•ž์— ๋ณ€์ˆ˜ ์„ ์–ธ ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. var number = 1; let number = 1; const number = 1; var - var ํ‚ค์›Œ๋“œ๋กœ ์„ ์–ธํ•œ ๋ณ€์ˆ˜๋Š” ์ค‘๋ณต ์„ ์–ธ์ด ๊ฐ€๋Šฅ (์ฒ˜์Œ ์„ ์–ธํ•œ ๋ณ€์ˆ˜์˜ ๊ฐ’์ด ๋ณ€๊ฒฝ๋จ) var x = 1; console.log(x); //1 var x = 2; console.log(x); //2 - var ํ‚ค๋“œ์›Œ๋กœ ์„ ์–ธํ•œ ๋ณ€์ˆ˜๋Š” ํ•จ์ˆ˜์˜ ์ฝ”๋“œ ๋ธ”๋ก๋งŒ์„ ์ง€์—ญ ์Šค์ฝ”ํ”„๋กœ ์ธ์ • => ๋ชจ๋‘ ์ „์—ญ ๋ณ€์ˆ˜๊ฐ€ ๋จ var x = 1; if(true) { var x = 2; } console.log(x); //2 - ๋Ÿฐํƒ€์ž„ ์ด์ „์— ๋ณ€์ˆ˜ ์„ ์–ธ, ์ดˆ๊ธฐํ™” ๋‘˜๋‹ค ์‹คํ–‰ console.log(x); //undefined var x; console.log(x);..
[Node.js] npm
ยท
๐Ÿ“Language/๐ŸŸข Node.js
npm : node package manager https://www.npmjs.com/ npm Bring the best of open source to you, your team, and your company Relied upon by more than 17 million developers worldwide, npm is committed to making JavaScript development elegant, productive, and safe. The free npm Registry has become the center of Java www.npmjs.com ํŒจํ‚ค์ง€ ์„ค์น˜ # ํ˜„์žฌ ํ”„๋กœ์ ํŠธ๋‚ด์— ์„ค์น˜ npm install {ํŒจํ‚ค์ง€ ์ด๋ฆ„} # ์ „์—ญ(global)์— ์„ค์น˜ npm install ..
[Node.js] Mac ๊ฐœ๋ฐœํ™˜๊ฒฝ ๊ตฌ์ถ•
ยท
๐Ÿ“Language/๐ŸŸข Node.js
์„ค์น˜ brew update brew install node node -v //node ๋ฒ„์ „ ํ™•์ธ npm -v //npm ๋ฒ„์ „ ํ™•์ธ node.js ๊ณต์‹ ๋ฌธ์„œ https://nodejs.org/dist/latest-v19.x/docs/api/ Index | Node.js v19.5.0 Documentation nodejs.org