Fichas
Flash Cards -List & Dictionary
Fichas del conjunto (33)
- 1Listlist is an ordered sequence which is mutable and made up of one or more elements.
- 2Lists are MutableIt means that the contents
of the list can be changed after it has been created. - 3List OperationsConcatenation,Repetition,Membership,
Slicing - 4range(n)returns a sequence of numbers
starting from 0, increases by 1 and ends
at n-1 (one number less than the specified
number i.e. is) - 5Built-in Functionsfunctions are defined as the functions whose functionality is pre-defined in Python.
- 6len()Returns the length of the list passed as
the argument - 7list()Creates an empty list if no argument is
passed
Creates a list if a sequence is passed as
an argument - 8append()Appends a single element passed as an
argument at the end of the list
A list can also be appended as an element
to an existing list - 9extend()Appends each element of the list passed
as argument at the end of the given list - 10insert()Inserts an element at a particular index
in the list - 11count()Returns the number of times a given
element appears in the list - 12find()Returns index of the first occurrence of
the element in the list. If the element is
not present, ValueError is generated - 13remove()Removes the given element from the
list. If the element is present multiple
times, only the first occurrence is
removed. If the element is not present,
then ValueError is generated - 14pop()Returns the element whose index is
passed as argument to this function
and also removes it from the list. If no
argument is given, then it returns and
removes the last element of the list - 15reverse()Reverses the order of elements in the
given list - 16sort()Sorts the elements of the given list in
place - 17sorted()It takes a list as parameter and creates
a new list consisting of the same elements
but arranged in ascending order - 18min()Returns minimum or smallest element
of the list - 19max()Returns maximum or largest element of
the list - 20sum()Returns sum of the elements of the list
- 21DictionariesThe data type dictionary falls under mapping. It is a mapping between a set of keys and a set of values. The key-value pair is called an item. A key is separated from its value by a colon(:) and consecutive items are separated
by commas. Items in dictionaries are unordered - 22Creating a DictionaryTo create a dictionary, the items entered are separated by commas and enclosed in curly braces. Each item is a key value pair, separated through colon (:). The keys in the dictionary must be unique and should be of any immutable data type i.e. number, string or tuple. The
values can be repeated and can be of any data type. - 23Membership OperationThe membership operator in checks if the key is present in the dictionary and returns True, else it returns False.
- 24Dictionaries are Mutablewhich implies that the
contents of the dictionary can be changed after it has been created. - 25Built in functions len()Returns the length or number of
key: value pairs of the dictionary
passed as the argument - 26dict()Creates a dictionary from a
sequence of key-value pairs - 27keys()Returns a list of keys in the
dictionary - 28values()Returns a list of values in the
dictionary - 29items()Returns a list of tuples
(key —value) pair - 30get()Returns the value corresponding
to the key passed as the argument
If the key is not present in the
dictionary it will return None - 31update()appends the key-value pair of
the dictionary passed as the
argument to the key-value pair of
the given dictionary - 32clear()Deletes or clear all the items of
the dictionary - 33del()Deletes the item with the given
key .To delete the dictionary from the
memory we write:
del Dict_name
Información
- Descripción
- Fichas sobre Flash Cards -List & Dictionary, creado por Aparna Dhirde el 17/03/2020.
- Creado por
- Aparna Dhirde
- Visitas
- 9
- Valoración