ICA-E - 1 - Portfolio 4 Lists

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

SCHOOL OF COMPUTING, ENGINEERING & DIGITAL

TECHNOLOGIES

Python Programming (CIS1028-N)


Name
Student Number
Portfolio No. 4 – Lists

Describe the following list terms and associated operations

List is a combination of values stored at one place and the values are
stored according to the capacity of the list. First we set the size of the list
List and then enter the values in the list.

Mylist(‘one’, ‘two’, ‘three’)

List indices are the number of values space in the list if the total size is 10
then the number of indices will be 9.
List indices
Print Mylist[1]

First index value is the head of the list from where the list has been
started.
List head
Print Mylist[0]

Last index value is the head of the list from where the list has been ended.
List tail
Print Mylist[9]

List type defends upon the values need to be store in the list it can be in
different types int, float and string etc.
check list type
If isinstance(obj,list)

A cut item is utilized to indicate how to slice a grouping. You can


likewise indicate the step, which permits you to for example cut just
Slice operator every other thing.

Slice(start, end, step)

If we have to delete any element of the list from the values of the list we
remove can do it by giving the index of the cell.
method
List.remove[20]

Python Programming (CIS1028-N) – ICA Element 1 Portfolio 4 1 of 3


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL
TECHNOLOGIES

Here we can use a builtin sort method to sort the


values of the list by using different types of
sort sorting techniques.
method
Mylist= (‘one’, ‘two’, ‘three’)
Mylist.sort()

Index method is a method in which we can use a


builtin method index and identify the index
index number of any element from the list.
method
Mylist= (‘one’, ‘two’, ‘three’)
A=Mylist.index(‘two’)

By using the builtin function reverse we can


reverse the values of the list for example the end
reverse node value will become the 1st value and so on.
method
Mylist= (‘one’, ‘two’, ‘three’)
Mylist.reverse()

Python Programming (CIS1028-N) – ICA Element 1 Portfolio 4 2 of 3

You might also like