The following code example shows a Program to Demonstrate Simple Functions on a List in Python.

Here’s a program to demonstrate some simple functions on a list in Python.

# Create a list of numbers
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# Use the len function to get the length of the list
print("Length of the list: ", len(numbers))

# Use the min function to get the minimum value in the list
print("Minimum value in the list: ", min(numbers))

# Use the max function to get the maximum value in the list
print("Maximum value in the list: ", max(numbers))

# Use the sum function to get the sum of the values in the list
print("Sum of the values in the list: ", sum(numbers))

# Use the sorted function to sort the list in ascending order
print("Sorted list in ascending order: ", sorted(numbers))

# Use the sorted function to sort the list in descending order
print("Sorted list in descending order: ", sorted(numbers, reverse=True))

In this program, we first create a list of numbers. Then, we use the len function to get the length of the list, the min and max functions to get the minimum and maximum values in the list, the sum function to get the sum of the values in the list, and the sorted function to sort the list in ascending and descending order. Finally, we print the results of these functions.


Further Reading

Python Practice Exercise

Examples of OpenCV Library in Python

Examples of Tuples in Python

Python List Practice Exercise

A Brief Introduction of Pandas Library in Python

A Brief Tutorial on NumPy in Python

programmingempire

princites.com

IITM Software Development Cell