๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ

ยทpython
tuple: An immutable sequence similar to a list.triple = (5, 10, 15)triple2 = 5, 10, 15When creating a tuple, you can either use or omit the paranthesis. ์ด ๊ธ€์—์„œ๋Š” ํŠœํ”Œ์ด ํŒŒ์ด์ฌ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋ช‡๊ฐ€์ง€ ๊ฐ„๋‹จํ•œ ์˜ˆ๋ฅผ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.  ํŒŒ์ด์ฌ์—์„œ๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ธ์ž๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” ํ•จ์ˆ˜๋“ค์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด sum ํ•จ์ˆ˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. a = sum(1, 3) # Set a = 4b = sum(1, 3, 5, 7) # Set b = 16๋ณด์‹œ๋‹ค์‹œํ”ผ 2๊ฐœ, 4๊ฐœ, ๋˜๋Š” ๊ทธ ์ด์ƒ์˜ ์ธ์ž๋ฅผ ์ž…๋ ฅ ๋ฐ›์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ sum ํ•จ์ˆ˜๋ฅผ ์ง์ ‘ ๊ตฌํ˜„ํ•˜์ž๋ฉด, asterisk (*) ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.def sum(*val..
ยทpython
Listlist: A mutable sequence* that grows or shrinks dynamically as new elements are added or removed.*sequence: A container that stores a collection of values that can be accessed by an integer index. (string, list, …) Use SQUARE BRACKETS [ ] to create a list.  ex) values = [32, 54, 67.5, 80, 110, 44.5] # A list with 6 elements Another way to create a list:  values = [4] sets values to the list..
ยทpython
ํŒŒ์ด์ฌ์œผ๋กœ ๊ธฐ์ดˆ์ ์ธ ํ”„๋กœ๊ทธ๋žจ์„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ•˜๋‹ค ๋ณด๋ฉด, ์˜ค๋ฅ˜๋ฅผ ํ•ธ๋“ค๋ง ํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค.  When user enters invalid input, it is common to abort the program. ๊ทธ๋ ‡๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, sys standard library module์— ์ •์˜๋œ exit ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. from sys import exitif not (userResponse == "n" or userResponse == "y"): exit("Error: you must enter either n or y.") exit(errorMessage) ํ˜•์‹์œผ๋กœ ํ”„๋กœ๊ทธ๋žจ terminate ์‹œ์— ์ถœ๋ ฅ๋  ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ์ธ์ž๋กœ ๋„ฃ์œผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.
ยทpython
There are some ways in Python to analyze string.  substring in sReturns True if the string s contains substring and False otherwise.if "-" is not in name: ...s.count(substring)Returns the number of non-overlapping occurrences of substring in s.s.endswith(substring)Returns True if the string s ends with the substring and False otherwise.s.startswith(substring)Returns True if the string s starts w..
Chan Lee
'๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก