Lists are used in Python to hold multiple values in one variable
<u>(a) Nested list</u>
A nested list is simply a list of list; i.e. a list that contains another list.
It is also called a 2 dimensional list.
An example is:
nested_list = [[ 1, 2, 3, 4] , [ 5, 6, 7]]
<u>(b) The “*” operator </u>
The "*" operator is used to calculate the product of numerical values.
An example is:
num1 = num2 * num3
<u>List slices </u>
This is used to get some parts of a list; it is done using the ":" sign
Take for instance, you want to get the elements from the 3rd to the 5th index of a list
An example is:
firstList = [1, 2 ,3, 4, 5, 6, 7]
secondList = firstList[2:5]
<u>The “+=” operator </u>
This is used to add and assign values to variables
An example is:
num1 = 5
num2 = 3
num2 += num1
<u>A list filter </u>
This is used to return some elements of a list based on certain condition called filter.
An example that prints the even elements of a list is:
firstList = [1, 2 ,3, 4, 5, 6, 7]
print(list(filter(lambda x: x % 2 == 0, firstList)))
<u>A valid but wrong list operation</u>
The following operation is to return a single list, but instead it returns as many lists as possible
def oneList(x, myList=[]):
myList.append(x)
print(myList)
oneList(3)
oneList(4)
Read more about Python lists at:
brainly.com/question/16397886