Python str() Function26 Sept 2024 | 1 min read Python str() converts a specified value into a string. SignatureParametersobject : It is the encoding of the object. The default value is UTF-8. encoding : It is the encoding of the object. The default value is UTF-8. errors : It specifies the actions that need to be performed if the decoding fails. ReturnIt returns a string object. Python str Function Example 1The below example shows the working of str(). Output: '4' Explanation: In the above example, we have taken a string value 4 in the str and returns a string '4' as an output. Next TopicPython Built in Functions |
Function function is used to set a value to the object's attribute. It takes three arguments an object, a string, and an arbitrary value, and returns none. It is helpful when we want to add a new attribute to an object and set a value...
2 min read
Function function is used to get remainder and quotient of two numbers. This function takes two numeric arguments and returns a tuple. Both arguments are required and numeric. This function has the following syntax. Signature divmod (number1, number2) Parameters number1: A numeric value, it is required. number2: A numeric value,...
1 min read
Function The python list() creates a list in python. Signature list(iterable) Parameters iterable (optional) - An object that can be a sequence( string, tuple etc.) or collection( set, dictionary etc.) or iterator object. Return It returns a list. Function Example 1 The below example create a list from sequence: string, tuple and list. #...
1 min read
Function The python getattr() function returns the value of a named attribute of an object. If it is not found, it returns the default value. Signature getattr(object, attribute, default) Parameters object: An object whose named attribute value is to be returned. attribute: Name of the attribute of which you want to...
1 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 function returns the reversed iterator of the given sequence. Signature reversed(sequence) Parameters sequence: It is a sequence that needs to be reversed. Return It returns the reversed iterator of the given sequence. Function Example 1 The above example shows the working of reversed for a sequence: string, tuple, list, and range....
1 min read
Function Python is a high-level, general-purpose programming language that is widely used in different fields like data science, web development, and automation. Python gives many built-in functions that make programming more straightforward and quicker. One such helpful function is len(), which is used to get the...
4 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 function is used to delete an attribute from a class. It takes two parameters first is an object of the class and second is an attribute which we want to delete. After deleting the attribute, it no longer available in the class and throws...
1 min read
Function In python, a set is a built-in class, and this function is a constructor of this class. It is used to create a new set using elements passed during the call. It takes iterable as an argument and returns a new set object. The...
1 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