Python pass statement
The Python pass statement is a null operation; nothing happens as pass statement is executed. However, the interpreter reads it and so if placed in functions, if, loops etc. this is taken as a statement.
The Python pass statement is a null operation; nothing happens as pass statement is executed. However, the interpreter reads it and so if placed in functions, if, loops etc. this is taken as a statement.
The max() function is used to return the maximum value for two or more arguments passed to it. If an iterable like a list is passed as an argument, it will return the largest item in the iterable.
Python len() method can be used for getting the length of a given string, sequence and collection.
The Python has a built-in method len() for getting the total number of items in a list. The len() method takes an argument where you may provide a list and it returns the length of given list.
The Python 3 input function enables us to take the user input from the keyboard. As a line of code containing the input function executes, the user will be prompted to enter the required information.
The sqrt(x) function is used to get the square root of the given number in Python. The sqrt() function is the part of math module so you need to import it before using in Python program.
The filter function is used to build an iterator (a list, tuple etc.) after taking an iterable and a function as parameters. The built iterator contains only those items that returned as true after passing to function.
The nameless or anonymous function can be created by using the keyword lambda. These are small functions that you may use when function objects are required.
The Python map() function is used to apply a function (custom or built-in) to each item of one or more iterables (lists, tuples, set etc.). The map returns iterable e.g. a list after applying the given function – yielding the result.
The Python join method concatenates the string of a given sequence. The sequence can be lists, tuple, range. The elements of a sequence are joined by a given separator e.g. by space, comma, tab etc.
If your list contains only string objects then you may use the join() method for converting the list objects into the string. Otherwise use the str() and map with join.
Python has a few methods to add items to the existing list. These methods are append, insert, and extend. Each of these methods is explained below with examples.
The sleep() is a method of time module that enables suspending the execution of current thread for the given time. The time is provided in seconds.
The items in a list of Python can be reversed in different ways. Using the reverse method and slice trick. Read full tutorial for code and examples.
The List in Python has a built-in method to sort the list in ascending or descending order. The method is called sort() and only specific to the lists.