Python Method

Python Method String Methods str.capitalize(): #Returns a copy of the string with its first character capitalized. str.upper(): #Converts all characters in the string to uppercase. str.lower(): #Converts all characters in the string to lowercase. str.strip(): #Returns a copy of the string with leading and trailing whitespace removed. str.split(separator): #Splits the string into a list of substrings based on the specified separator. str.join(iterable): #Joins the elements of an iterable (e.g., a list) into a string using the string as a separator. List Methods list.append(element): #Adds an element to the end of the list. list.extend(iterable): #Extends the list by appending elements from the iterable. list.insert(index, element): #Inserts an element at the specified index. list.remove(element): #Removes the first occurrence of the specified element from the list. list.pop(index): #Removes and returns the element at the specified index. If no index is specified, removes and returns the last element. list.index(element): #Returns the index of the first occurrence of the specified element. list.sort(): #Sorts the elements of the list in ascending order. list.reverse(): #Reverses the order of the elements in the list. Dictionary Methods dict.keys(): #Returns a view of all keys in the dictionary. dict.values(): #Returns a view of all values in the dictionary. dict.items(): #Returns a view of all key-value pairs in the dictionary. dict.get(key, default): #Returns the value for the specified key. If the key is not found, it returns the default value. dict.pop(key): #Removes the item with the specified key and returns its value. dict.update(iterable): #Updates the dictionary with elements from another iterable or dictionary. File Methods open(filename, mode): #Opens a file and returns a file object. file.read(size): #Reads and returns the specified number of characters from the file. file.readline(): #Reads a single line from the file. file.readlines(): #Reads all lines from the file and returns them as a list. Other Common Methods len(iterable): #Returns the number of items in an iterable (e.g., a list, string, or dictionary). type(object): #Returns the type of an object. range([start], stop, [step]): #Returns a sequence of numbers from start to stop with the specified step.

November 23, 2023 · 2 min · 338 words · kidtz

Javascript Method

JavaScript Method Array Methods Adds one or more elements to the end of an array. push(): Removes the last element from an array. pop(): Removes the first element from an array. shift(): Adds one or more elements to the beginning of an array. unshift(): Returns a shallow copy of a portion of an array. slice(): Changes the contents of an array by removing or replacing existing elements. splice(): Returns the first index at which a given element is found in the array. indexOf(): Calls a function for each element in the array. forEach(): Creates a new array with the results of calling a provided function on every element in the array. map(): Creates a new array with all elements that pass the test implemented by the provided function. filter(): Applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value. reduce(): String Methods Combines two or more strings. concat(): Returns the character at the specified index. charAt(): Returns the index within the calling string object of the first occurrence of the specified value. indexOf(): Returns the part of the string between the start and end indexes. substring(): Extracts a section of a string and returns it as a new string. slice(): Converts a string to uppercase. toUpperCase(): Converts a string to lowercase. toLowerCase(): Removes whitespace from both ends of a string. trim(): Object Methods Returns an array of a given object's own property names. Object.keys(): Returns an array of a given object's own enumerable property values. Object.values(): Returns an array of a given object's own enumerable property [key, value] pairs. Object.entries(): Math Methods ...

November 23, 2023 · 2 min · 365 words · kidtz