Method
-
[Python tutorial] 24. Set Methods코딩/Python 2022. 12. 21. 17:29
set.add(elmnt) Adds an element to the set fruits = {"apple", "banana", "cherry"} fruits.add("orange") set.clear() Removes all the elements from the set fruits = {"apple", "banana", "cherry"} fruits.clear() set.copy() Returns a copy of the set fruits = {"apple", "banana", "cherry"} x = fruits.copy() set.difference(set) Returns a set containing the difference between two or more sets x = {"apple",..
-
[Python tutorial] 23. Tuple Methods코딩/Python 2022. 12. 21. 17:28
tuple.count(value) Returns the number of times a specified value occurs in a tuple thistuple = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5) x = thistuple.count(5) tuple.index(value) Searches the tuple for a specified value and returns the position of where it was found thistuple = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5) x = thistuple.index(8)
-
[Python tutorial] 21. List/Array methods코딩/Python 2022. 12. 21. 17:18
list.append(elmnt) Adds an element at the end of the list fruits = ['apple', 'banana', 'cherry'] fruits.append("orange") list.clear() Removes all the elements from the list fruits = ['apple', 'banana', 'cherry', 'orange'] fruits.clear() list.copy() Returns a copy of the list fruits = ['apple', 'banana', 'cherry', 'orange'] x = fruits.copy() list.count(value) Returns the number of elements with t..
-
[Python tutorial] 20. String methods코딩/Python 2022. 12. 21. 17:18
string.capitalize() Converts the first character to upper case txt = "hello, and welcome to my world." x = txt.capitalize() print (x) string.casefold() Converts string into lower case txt = "Hello, And Welcome To My World!" x = txt.casefold() print(x) string.center(length, character) Returns a centered string txt = "banana" x = txt.center(20) print(x) string.count(value, start, end) Returns the ..