Upload
alan-dtodz-crew
View
229
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Materi
Citation preview
Array Based SequenceinPython
List - 1
Format to Declare list variable in Python, we can use a pair of parentheses ([])Example : shoplist = ['apple', 'mango', 'carrot', 'banana']
To print list's content, we can use for loop or we can use print command.Example print shoplist
List - 2
Available methods in list :append This method is used to append list's item in the last of item
insert This method is used to insert an item's list in any order
Sort this method is used to sort the list's item
del use to del item in any index
Tuple
Tuples are used to hold together multiple objects.
Think of them as similar to lists, but without the extensive functionality that the list class gives you.
One major feature of tuples is that they are immutable
Tuples are usually used in cases where a statement or a user-defined function can safely assume that the collection of values i.e. the tuple of values used will not change
Dictionary
A dictionary is like an address-book where you can find the address or contact details of a person by knowing only his/her name
In dictionary we associate keys (name) with values (details).
Note that the key must be unique
Note that you can use only immutable objects (like strings) for the keys of a dictionary but you can use either immutable or mutable objects for the values of the dictionary.
Sequence
Lists, tuples and strings are examples of sequences
The major features is that they have membership tests (i.e. the in and not in expressions) and indexing operations.
The three types of sequences mentioned above - lists, tuples and strings, also have a slicing operation which allows us to retrieve a slice of the sequence i.e. a part of the sequence.
Set
Lists, tuples and strings are examples of sequences
The major features is that they have membership tests (i.e. the in and not in expressions) and indexing operations.
The three types of sequences mentioned above - lists, tuples and strings, also have a slicing operation which allows us to retrieve a slice of the sequence i.e. a part of the sequence.
Reference
When you create an object and assign it to a variable, the variable only refers to the object and does not represent the object itself! That is, the variable name points to that part of your computer's memory where the object is stored.
Reference Byte of Python, Chapter Data StructuresData Structure and Algorithm in Python Chapter 5
Muokkaa otsikon tekstimuotoa napsauttamalla
Muokkaa jsennyksen tekstimuotoa napsauttamallaToinen jsennystasoKolmas jsennystasoNeljs jsennystasoViides jsennystasoKuudes jsennystasoSeitsems jsennystasoKahdeksas jsennystasoYhdekss jsennystaso