Blog
COPYING A LIST:
Occasionally you will want to copy a list one simple way to copy your list is to use to copy method
PYTHON LIST SORTING
In this section we sort list elements python has built in list method sort ( ) and sorted ( ) function for doing sorting
Example: # sorting . PY
N=[3, 4, 5, 1, 2, 8, 9, 7, 6]
Print (n)
N . sort(n)
The sort ( ) method has an optional key parameters the parameter specifies a function to be called on each list element prior making comparisons
SETS
The set data will be print unordered list :
A set data type is defined as an “unordered” collection of distinct hash able objects
According to the python 3 documentation you can see a set for membership testing, removing duplicates from a sequence and computing mathematical operations , like intersection , union , difference , and symmetric difference
There is two types of set built into the python language
- Set which is mutable
- Frozen set which is immutable and hash able
- Create set
- Accessing a set members
- Changing items
- Adding items
- Removing items
- Clearing and deleting a set
- Set operations
- CREATING SET:
The set data is creating process will be creating set
- Accessing set members :
You can check if an item is in a set by using python is operator
- Changing items :
Once a set is created you cannot change and of its items . how ever you can add new a set
How to removing items :
We can remove set items from sets in several possible ways
We can use :
- Remove ( )
- Discard ( )
- Pop ( )
Using . Remove ( ) :
The remove () method will select to remove
Author:Yoktha
Leave a Reply Cancel reply
You must be logged in to post a comment.