๐Ÿ“š ์Šคํ„ฐ๋””/ํŒŒ์ด์ฌ ์Šคํ„ฐ๋”” ๊ณผ์ œ ์ œ์ถœ 121

[4ํŒ€/๊น€์œค] 6์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ - ๋ฌธ์ž์—ด

1. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์„ ๋•Œ, ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค. a = "H-e-l-l-o-P-y-t-h-o-n" print(a[::3]) 2. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์„ ๋•Œ, ์‹คํ–‰ ๊ฒฐ๊ณผ๋กœ ์•Œ๋งž์€ ๊ฒƒ์€? value_l = "5" value_2 = "5 - 2 - 10 - 10".split("-")[-1] print(int(value_l)) * 3 + float(value_2) 5.0 10.0 ์—๋Ÿฌ ๋ฐœ์ƒ 15.0 25.0 -> ๋‹ต : 3. ์—๋Ÿฌ ๋ฐœ์ƒ 3. ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ”๋“œ ์ž‘์„ฑ์‹œ, ๋นˆ ์นธ a, b์— ์•Œ๋งž์€ ์ฝ”๋“œ๋ฅผ ๊ฐ๊ฐ ์ž‘์„ฑํ•˜์‹œ์˜ค. sentence = "Hello, my name is python?!" print(sentence[0]+sentence[ a ]+sentence[ b ]) #์‹คํ–‰ ๊ฒฐ๊ณผ : H,..

[4ํŒ€/๊น€์œค] 5์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ - ํ•จ์ˆ˜

1. ์ด๋ฆ„์„ ์ธ์ˆ˜๋กœ ๋ฐ›์•„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ธ์‚ฟ๋ง์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค. ํ™๊ธธ๋™๋‹˜ ์•ˆ๋…•ํ•˜์„ธ์š”! -> ๋‹ต : name = input("name : ") print(f"{name}๋‹˜ ์•ˆ๋…•ํ•˜์„ธ์š”!") 2. ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ–ˆ์„ ๋•Œ์˜ ์ถœ๋ ฅ ๊ฒฐ๊ณผ๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค. def f(x): y = x x = 7 return y * x x = 4 print(f(3)) print(x) -> ๋‹ต : 21, 4 3. f(3)์—์„œ์˜ x์™€ y์˜ ๊ฐ’์ด ๋ฌด์—‡์ธ์ง€ ์ž‘์„ฑํ•˜์‹œ์˜ค. -> ๋‹ต : x๊ฐ’ : 7, y๊ฐ’: 3 4. ์ง€์—ญ๋ณ€์ˆ˜์™€ ์ „์—ญ๋ณ€์ˆ˜ ๊ฐ๊ฐ ํ•˜๋‚˜์”ฉ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถœ๋ ฅํ•˜์‹œ์˜ค. Value : 10 Value : 20 -> ๋‹ต : def pValue(Value): print("Value :", Value) pValue(10) Value..

[2ํŒ€/์œค์„œํ˜„] 6์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ - ๋ฌธ์ž์—ด

์ •๋‹ต : 3๋ฒˆ (.islower ์€ ๋ฌธ์ž๊ฐ€ ์†Œ๋ฌธ์ž์ธ์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ช…) ์ •๋‹ต : 2๋ฒˆ #3 ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์„ ๋•Œ, ์‹คํ–‰ ๊ฒฐ๊ณผ๋กœ ์•Œ๋งž์€ ๊ฒƒ์€? ์ •๋‹ต : 2๋ฒˆ(firstjword๋ž‘ secondjword๊ฐ€ first_word์™€ second_word๋กœ ๊ฐ€์ •ํ–ˆ์„ ๋•Œ) #4 sentence ๋ฌธ์ž์—ด์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ํ˜•ํƒœ๋กœ ์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด์„ ์ƒ์„ฑํ•˜์˜€๋‹ค. ์ด ์ค‘ ๊ธฐ์กด ๋ฌธ์ž ์—ด sentence์™€ ๊ฒฐ๊ณผ๊ฐ’์ด ๊ฐ™์€ ๊ฒƒ์€ ๋ฌด์—‡์ธ๊ฐ€? sentence = 'Life Is Short You Need Python' a = sentence[-15:20] b = sentence.lower() c = sentence[๏ผš20] d = sentence[0๏ผš] e = sentence[๏ผš-l] 1. a 2.b 3.c 4.d 5. ..

[4ํŒ€ / ๊น€์œ ๊ฒฝ] 5์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ - ํ•จ์ˆ˜ํ˜•

๋ฌธ์ œ1: ํ•จ์ˆ˜ "๋น„ํŠธ์ฝ”์ธ" ๋ฌธ์ž์—ด์„ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋Š” print_coin() ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•˜๋ผ. def print_coin(): print("๋น„ํŠธ์ฝ”์ธ") ๋ฌธ์ œ2: ํ˜ธ์ถœ ๋ฌธ์ œ1์—์„œ ์ •์˜ํ•œ ํ•จ์ˆ˜๋ฅผ 100๋ฒˆ ํ˜ธ์ถœํ•˜๋ผ. def print_coin(): print("๋น„ํŠธ์ฝ”์ธ") for i in range(100): print_coin() ๋ฌธ์ œ3: ํ•จ์ˆ˜์™€ ์—๋Ÿฌ ์•„๋ž˜์˜ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ์ด์œ ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•˜๋ผ. hello() def hello(): print("Hi") NameError: name 'hello' is not defined ์ •๋‹ต: ํ•จ์ˆ˜์˜ ์ •์˜๋ฅผ ๋จผ์ € ํ•œ ํ›„์— ํ˜ธ์ถœ์„ ํ•ด์•ผํ•œ๋‹ค. ๋ฌธ์ œ4: ํ•จ์ˆ˜ ์•„๋ž˜ ์ฝ”๋“œ์˜ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์˜ˆ์ธกํ•˜๋ผ. ์˜ˆ์ธก: A C B E D ๋ฌธ์ œ5: ํ•จ์ˆ˜ ์•„๋ž˜ ์ฝ”๋“œ์˜ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์˜ˆ์ธกํ•˜๋ผ. ์˜ˆ์ธก: B..

[3ํŒ€ / ๊น€์€์ˆ˜] 5์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ - ํ•จ์ˆ˜ํ˜•

1๋ฒˆ ์ •๋‹ต : 1๋ฒˆ 2๋ฒˆ ์ •๋‹ต:2 3๋ฒˆ ์ •๋‹ต: 3๋ฒˆ print(f(3))์„ ํ•˜๋ฉด y=3, x=7์ด๋‹ˆ ๋ฐ˜ํ™˜ ๊ฐ’์œผ๋กœ 21์ด ๋‚˜์˜ต๋‹ˆ๋‹ค. print(x)๋ฅผ ์‹œํ–‰ํ•˜๋ฉด ์ „์—ญ๋ณ€์ˆ˜ x=4์ด ์˜ํ•ด 4๊ฐ€ ๋‚˜์˜ต๋‹ˆ๋‹ค. 4๋ฒˆ ์ •๋‹ต: 1๋ฒˆ ํ‚ค์›Œ๋“œ ์ธ์ˆ˜๋Š” ์ˆœ์„œ์— ์ƒ๊ด€์—†์ด ์›ํ•˜๋Š” ๋ณ€์ˆ˜์— ์ธ์ˆ˜๋ฅผ ๋„ฃ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. 5๋ฒˆ ์ •๋‹ต : 1๋ฒˆ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์—†์„ ๋•Œ ๋ฐ˜ํ™˜๊ฐ’๋งŒ ์žˆ๋Š” ๊ฒฝ์šฐ ๊ทธ ๋ฐ˜ํ™˜๊ฐ’๋งŒ ๋„์ถœ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. 6๋ฒˆ ์ •๋‹ต: 1๋ฒˆ ์ „์—ญ๋ณ€์ˆ˜๊ฐ€ ๋” ์šฐ์„ ์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. 7๋ฒˆ ์ •๋‹ต: 1๋ฒˆ say_myselfํ•จ์ˆ˜๊ฐ€ ๋‹ค ๋Œ์•„๊ฐ„ ๋’ค if๋ฌธ์ด ์‹œํ–‰๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฆ„ ๋‚˜์ด ์„ฑ๋ณ„ ์ˆœ์„œ๋Œ€๋กœ ๊ฐ’์ด ์ถœ๋ ฅ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. 8๋ฒˆ ์ •๋‹ต : Value: 10 Value: 20 examํ•จ์ˆ˜์•ˆ์— ์žˆ๋Š” x๋Š” ์ง€์—ญ๋ณ€์ˆ˜์ด๊ธฐ ๋•Œ๋ฌธ์— 10์ด ๋‚˜์˜ค๊ณ  ๋งˆ์ง€๋ง‰ ์ค„์—๋Š” ์ „์—ญ๋ณ€์ˆ˜ ๊ฐ’์ธ 20์ด ๋“ค์–ด..

[2ํŒ€/์ด์œ ์ง„] 5์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ- ํ•จ์ˆ˜

ํŒŒ์ด์ฐธ์ด ์‹คํ–‰๋˜์ง€ ์•Š์•„ replit ์‚ฌ์ดํŠธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ณผ์ œ ์ง„ํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. 1. ๋‘ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ ๋”ํ•œ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜(add_numbers)๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค. 2. ๋‘ ์ˆ˜๋ฅผ ๋น„๊ตํ•˜๋Š” compare_numbers ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. (๋ฐฑ์ค€ 1330) ์ž…๋ ฅ ์กฐ๊ฑด: ์ฒซ์งธ ์ค„์— ๋‘ ์ •์ˆ˜ A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (−10,000 ≤ A, B ≤ 10,000) 3. ๋ฌธ์ž์—ด์„ ์ž…๋ ฅ ๋ฐ›์•„ ๊ฑฐ๊พธ๋กœ ๋’ค์ง‘์€ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜(reverse_string)๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค - ํ•ด๊ฒฐ๋ชปํ•จ 4. ์ •์ˆ˜ n๊ฐœ๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, n๊ฐœ์˜ ํ•ฉ์„ ๊ตฌํ•˜๋Š” solve ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์‹œ์˜ค. (๋ฐฑ์ค€ 15596) 5. ๋ฌธ์ž์—ด๊ณผ ๋ฌธ์ž๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ ํ•ด๋‹น ๋ฌธ์ž์—ด์—์„œ ํ•ด๋‹น ๋ฌธ์ž๊ฐ€ ๋ช‡ ๋ฒˆ ๋‚˜์˜ค๋Š”์ง€ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜ (count_char)๋ฅผ ์ž‘์„ฑํ•˜..

[1์กฐ/์ด๋„์—ฐ] 5์ฐจ์‹œ ํŒŒ์ด์ฌ๊ณผ์ œ - ํ•จ์ˆ˜

1) c 2) 100 3) 3 4) 21, 4 5) c 6) a 7) ์•„๋ฌด๊ฒƒ๋„ ๋‚˜์˜ค์ง€ ์•Š๋Š”๋‹ค. 8) 9) none 10) ๋ฐ˜๋ณต๋˜๋Š” ์ผ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด์„œ์ด๋‹ค. 11) def example(): print("์•ˆ๋…•ํ•˜์„ธ์š”") example() 12) a = int(input("a์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์„ธ์š”")) b = int(input("b์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์„ธ์š”")) def sum(a,b): print("%d์™€ %d์˜ ํ•ฉ์€ %d์ž…๋‹ˆ๋‹ค."%(a,b,a+b)) sum(a,b)

[1ํŒ€/๊น€์€ํ˜œ]5์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ - ํ•จ์ˆ˜

๋‘ ๊ฐœ์˜ ์ธ์ˆ˜๋ฅผ ๋ฐ›์•„์„œ ๊ทธ ํ•ฉ์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”. ํ•จ์ˆ˜ ์ด๋ฆ„์€ add_numbers ๋กœ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”. def add_numbers(x,y): result = x + y return result hap = add_numbers(1,2) print("1+2์˜ add_numbers()ํ•จ์ˆ˜ ๊ฒฐ๊ณผ๋Š” %d" % hap) 2. ๋ฌธ์ž์—ด์„ ์ธ์ˆ˜๋กœ ๋ฐ›์•„ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”. ํ•จ์ˆ˜ ์ด๋ฆ„์€ string_length ๋กœ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”. ํžŒํŠธ : len( ) def string_length(): return "์•ˆ๋…•ํ•˜์„ธ์š”" print(len("์•ˆ๋…•ํ•˜์„ธ์š”")) 3.๋ชฉ๋ก์„ ์ธ์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๊ณ  ๋ชฉ๋ก์—์„œ ๊ฐ€์žฅ ํฐ ์š”์†Œ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”. ํ•จ์ˆ˜ ์ด๋ฆ„์€ find_max ๋กœ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”. ํžŒํŠธ : ..

[3ํŒ€/์•ˆ์†Œ์—ฐ] 5์ฐจ์‹œ ํŒŒ์ด์ฌ ๊ณผ์ œ-ํ•จ์ˆ˜

1๋ฒˆ Input is 100 2๋ฒˆ 21 4 3๋ฒˆ - 1๋ฒˆ 4๋ฒˆ 5๋ฒˆ_ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜์ง€ ์•Š์Œ 5๋ฒˆ 5๋ฒˆ_ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜์ง€ ์•Š์Œ 6๋ฒˆ ๋‚˜์˜ ์ด๋ฆ„์€ ์ตœ์ฃผ์˜ ์ž…๋‹ˆ๋‹ค. ๋‚˜์ด๋Š” 20์‚ด์ž…๋‹ˆ๋‹ค. ์—ฌ์ž์ž…๋‹ˆ๋‹ค. 7๋ฒˆ ['Seo', 'Any', 'Inc', 'Jej'] 8๋ฒˆ Value: 10 Value: 20 9๋ฒˆ None_list.sort๋Š” ์ •๋ ฌ๋งŒ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— 10๋ฒˆ 111 222 333 222