Python reversed() Function26 Sept 2024 | 1 min read Python reversed() function returns the reversed iterator of the given sequence. SignatureParameterssequence: It is a sequence that needs to be reversed. ReturnIt returns the reversed iterator of the given sequence. Python reversed() Function Example 1The above example shows the working of reversed for a sequence: string, tuple, list, and range. Output: ['a', 'v', 'a', 'J'] ['a', 'v', 'a', 'J'] [11, 10, 9, 8] [5, 7, 2, 1] Explanation: In the above example, we have taken a string that consists the value "Java", and it prints the reversed string value as the output. In the second case, we have taken a tuple value that consists of the same value, and it prints the reversed tuple value as the output. In the third case, we have taken a range that consists of a range of numeric values, and it prints the reversed range values as output. In the fourth case, we have taken a list that consists of some numeric values, and it prints the reversed list value as output. Next TopicPython Built in Functions |
Function The python hasattr() function returns true if an object has given named attribute. Otherwise, it returns false. Signature hasattr(object, attribute) Parameters object: It is an object whose named attribute is to be checked. attribute: It is the name of the attribute that you want to search. Return It returns true if an...
1 min read
Function The python ascii() function returns a string containing a printable representation of an object and escapes the non-ASCII characters in the string using \x, \u or \U escapes. Signature ascii(object) Parameters object: It takes an object like strings, list etc. Return It returns a readable version of an object and replaces...
1 min read
Function function is used to get input from the user. It prompts for the user input and reads a line. After reading data, it converts it into a string and returns that. It throws an error EOFError if EOF is read. Signature input ([prompt]) Parameters prompt: It is a...
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 The python float() function returns a floating-point number from a number or string. A floating-point number, or float, is a mathematical value that contains a decimal point. Floats can be positive or negative and can address both whole numbers and fractional values. In Python, the...
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 function is used to compute the powers of a number. It returns x to the power of y modulus z if a third argument(z) is present, i.e. (x, y) % z. Signature pow(x, y, z) Parameters x: It is a number, a base y: It is a number, an...
1 min read
Function The python all() function accepts an iterable object (such as list,dictionary etc.). It returns True if all items in passed iterable are true, otherwise it returns False. If the iterable object is empty, the all() function returns True. Signature all (iterable) Parameters iterable - The objects which contain...
1 min read
Function converts a specified value into a string. Signature str(object, encoding=encoding, errors=errors) Parameters object : 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...
1 min read
Function Python, one of the most famous programming languages, offers a scope of inherent capabilities that improve on different undertakings. The range() function stands out as a versatile instrument for iteration and sequence creation. We will look the syntax, parameters, and practical applications of the range()...
2 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