×


Category: WordPress


Python filter() Function - Explained with Examples

This article covers how to use the filter() function in Python. In tact, the filter() function extracts elements from an iterable (list, tuple etc.) for which a function returns True.


filter() Arguments

The filter() function takes two arguments:

  • function - a function.
  • iterable - an iterable like sets, lists, tuples etc.


Python round() Function in Linux

This article covers how to use the round() function in Python. In fact, the round() function returns a floating-point number rounded to the specified number of decimals.


round() Return Value

The round() function returns the:

  • nearest integer to the given number if ndigits is not provided.
  • number rounded off to the ndigits digits if ndigits is provided.


Python sum() Function in Linux - Step by step guide ?

This article covers how to use the sum() function in Python. In fact, the sum() function adds the items of an iterable and returns the sum. Also it calculates the total of all numerical values in an iterable. sum() works with both integers and floating-point numbers. The sum() function has an optional parameter to add a number to the total.


Python len() Function - With examples ?

This article covers how to use the len() function in Python. In fact, the Python len() method is a built-in function that can be used to calculate the length of any iterable object. So, if you want to get the length of a string, list, dictionary, or another iterable object in Python, the len() method can be useful.


Python While Loop in Linux

This article covers how to use the while loop in Python. In fact, Loops are used in programming to repeat a specific block of code.


Python slice() Function in Linux

This article covers how to use the slice() function in Python. In fact, the slice() function returns a slice object that is used to slice any sequence (string, tuple, list, range, or bytes).



Example of slice() function in Python:

text = 'Python Programing'
# get slice object to slice Python
sliced_text = slice(6)
print(text[sliced_text])

The will be Output: 

Python