Breaking News

New Updates

Python All Metheds



String



Here is a list of all the methods available for string objects in Python 3:

capitalize(): Return a copy of the string with the first character capitalized and the rest lowercase.
casefold(): Return a copy of the string with all the characters converted to lowercase.
center(): Return a centered string padded with a specified character.
count(): Return the number of occurrences of a substring in the string.
encode(): Return an encoded version of the string.
endswith(): Return True if the string ends with a specified suffix.
expandtabs(): Return a copy of the string with tab characters replaced by spaces.
find(): Return the index of the first occurrence of a substring in the string.
format(): Return a formatted version of the string.
index(): Like find(), but raise a ValueError if the substring is not found.
isalnum(): Return True if all characters in the string are alphanumeric.
isalpha(): Return True if all characters in the string are alphabetic.
isdecimal(): Return True if all characters in the string are decimal characters.
isdigit(): Return True if all characters in the string are digits.
isidentifier(): Return True if the string is a valid identifier.
islower(): Return True if all characters in the string are lowercase.
isnumeric(): Return True if all characters in the string are numeric.
isprintable(): Return True if all characters in the string are printable.
isspace(): Return True if all characters in the string are whitespace.
istitle(): Return True if the string is titlecased.
isupper(): Return True if all characters in the string are uppercase.
join(): Join a list of strings into a new string using the original string as a separator.
ljust(): Return a left-justified string padded with a specified character.
lower(): Return a copy of the string with all uppercase characters converted to lowercase.
lstrip(): Return a copy of the string with leading whitespace characters removed.
maketrans(): Return a translation table for use with translate().
partition(): Return a tuple containing the parts of the string before and after a specified separator.
replace(): Return a copy of the string with all occurrences of a substring replaced


List



Here is a list of all the methods available for list objects in Python 3:

append(): Add an item to the end of the list.
clear(): Remove all items from the list.
copy(): Return a shallow copy of the list.
count(): Return the number of occurrences of an item in the list.
extend(): Add all items from another iterable to the end of the list.
index(): Return the index of the first occurrence of an item in the list.
insert(): Insert an item at a specified position in the list.
pop(): Remove and return the item at a specified position in the list. If no index is specified, remove and return the last item in the list.
remove(): Remove the first occurrence of an item in the list. If the item is not found, raise a ValueError.
reverse(): Reverse the order of the items in the list.
sort(): Sort the items in the list in ascending order or in a specified order.

These methods provide various functionalities for working with lists in Python 3.


Dectnory

Here is a list of all the methods available for dictionary objects in Python 3:

clear(): Remove all elements from the dictionary.
copy(): Return a shallow copy of the dictionary.
fromkeys(): Create a new dictionary with keys from iterable and values set to value.
get(): Return the value for key if key is in the dictionary, else default.
items(): Return a new object of the dictionary's items (key, value pairs).
keys(): Return a new object of the dictionary's keys.
pop(): Remove and return the value for key if key is in the dictionary, else default.
popitem(): Remove and return an arbitrary (key, value) pair from the dictionary.
setdefault(): Return the value for key if key is in the dictionary, else insert key with a value of default and return default.
update(): Update the dictionary with the key/value pairs from other, overwriting existing keys.
values(): Return a new object of the dictionary's values.

These methods provide various functionalities for working with dictionaries in Python 3.


Set

Here is a list of all the methods available for set objects in Python 3:
add(): Add an element to the set.
clear(): Remove all elements from the set.
copy(): Return a shallow copy of the set.
difference(): Return the difference between two or more sets as a new set.
difference_update(): Remove all elements of another set from this set.
discard(): Remove an element from the set if it is a member. If the element is not a member, do nothing.
intersection(): Return the intersection of two or more sets as a new set.
intersection_update(): Update the set with the intersection of itself and another.
isdisjoint(): Return True if two sets have no elements in common.
issubset(): Return True if another set contains this set.
issuperset(): Return True if this set contains another set.
pop(): Remove and return an arbitrary set element. Raise KeyError if the set is empty.
remove(): Remove an element from the set; it must be a member. If the element is not a member, raise a KeyError.
symmetric_difference(): Return the symmetric difference of two sets as a new set.
symmetric_difference_update(): Update the set with the symmetric difference of itself and another.
union(): Return the union of sets as a new set.
update(): Update the set with another set, or any other iterable.

These methods provide various functionalities for working with sets in Python 3.

Python inbuild funtoin

As a beginner, it can be helpful to know some of the built-in functions in Python. Here are some examples:

print(): Used to print a message to the console.

len(): Used to determine the length of an iterable.

abs(): Returns the absolute value of a number.

type(): Returns the data type of a variable.

max(): Returns the largest item in an iterable.

min(): Returns the smallest item in an iterable.

range(): Returns a sequence of numbers from start to stop, incremented by step.

sum(): Returns the sum of all items in an iterable.

sorted(): Returns a sorted list of an iterable.

input(): Reads user input from the console.

These are just a few examples of Python's built-in functions. There are many more, and you can find a complete list in the Python documentation.



Creadit: @programmer_girl

No comments