Python tuple() Function26 Sept 2024 | 1 min read Python tuple() function is used to create a tuple object. SignatureParametersIterable: It is a sequence, collection, or an iterator object. ReturnIt returns a tuple. Python tuple() Function Example 1The below example creates tuple using tuple(). Output: t1= () t2= (1, 6, 9) t1= ('J', 'a', 'v', 'a') t1= (4, 5) Explanation: In the above example, we have taken an empty tuple named as t1 which returns empty values. In the second case, we have created a tuple from a list, i.e., t2 which return its values. In the third case, we have created a tuple from the string which returns the string values. In the fourth case, we have created a tuple from the dictionary, which returns its values. Next TopicPython Built in Functions |
Function The python bytes() function in Python is used for returning a bytes object. It is an immutable version of bytearray() function. It can create empty bytes object of the specified size. Signature bytes(source) bytes(encoding) bytes(error) Parameters source is used to initialize the bytes object. It is an optional parameter. encoding is optional unless...
1 min read
Function function is used to get the smallest element from the collection. This function takes two arguments, first is a collection of elements and second is key and returns the smallest element from the collection. Signature min (collection[, key]) Parameters collection: It is a comma-separated list of elements. key: Specifies...
1 min read
Function The python memoryview() function returns a memoryview object of the given argument. Before we come to the memoryview, we have to understand about Python's Buffer Protocol. Buffer Protocol provides a way to access internal data of an object. This internal data is a memory array or a...
2 min read
Function The python iter() function is used to return an iterator object. It creates an object which can be iterated one element at a time. Signature iter(object, sentinel) Parameters object: An iterable object. sentinel (optional)- It is a special value that represents the end of a sequence. Return It returns an iterator object. ...
1 min read
Function The python frozenset() function returns an immutable frozenset object initialized with elements from the given iterable. Signature frozenset(iterable) Parameters iterable: An iterable object such as list, tuple etc. Return It returns an immutable frozenset object initialized with elements from the given iterable. Function Example 1 The below example shows the working of...
1 min read
Function function is used to get help related to the object passed during the call. It takes an optional parameter and returns help information. If no argument is given, it shows the Python help console. It internally calls python's help function. Signature help(object) Parameters object: It can be any...
2 min read
Function function is used to sort a sequence of elements. The sorted() function can be used to sort a variety of data structures or complex objects effortlessly in ascending or descending order. By default, it sorts elements in ascending order. The sorted function takes three arguments...
6 min read
Function The python bytearray() function returns a bytearray object and can convert objects into bytearray objects, or create an empty bytearray object of the specified size. Signature bytearray(x, encoding, error) Parameters x (optional) : It is the source that initializes the array of bytes. encoding (optional) : It is an...
1 min read
Function Python has() function is used to get the hash value of an object. Python calculates the hash value by using the hash algorithm. The hash values are integers an used to compare dictionary keys during a dictionary lookup. We can hash only these types: Hashable types:...
2 min read
Function function returns an enumerated object. It takes two parameters first is a sequence of elements and the second is the start index of the sequence. We can get sequence elements either through a loop or () method. The () method of the iterator returned...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India