Flash Cards -List & Dictionary

Beschreibung

Karteikarten am Flash Cards -List & Dictionary, erstellt von Aparna Dhirde am 17/03/2020.
Aparna Dhirde
Karteikarten von Aparna Dhirde, aktualisiert more than 1 year ago
Aparna Dhirde
Erstellt von Aparna Dhirde vor mehr als 4 Jahre
7
0

Zusammenfassung der Ressource

Frage Antworten
List list is an ordered sequence which is mutable and made up of one or more elements.
Lists are Mutable It means that the contents of the list can be changed after it has been created.
List Operations Concatenation,Repetition,Membership, Slicing
range(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)
Built-in Functions functions are defined as the functions whose functionality is pre-defined in Python.
len() Returns the length of the list passed as the argument
list() Creates an empty list if no argument is passed Creates a list if a sequence is passed as an argument
append() 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
extend() Appends each element of the list passed as argument at the end of the given list
insert() Inserts an element at a particular index in the list
count() Returns the number of times a given element appears in the list
find() Returns index of the first occurrence of the element in the list. If the element is not present, ValueError is generated
remove() 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
pop() 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
reverse() Reverses the order of elements in the given list
sort() Sorts the elements of the given list in place
sorted() It takes a list as parameter and creates a new list consisting of the same elements but arranged in ascending order
min() Returns minimum or smallest element of the list
max() Returns maximum or largest element of the list
sum() Returns sum of the elements of the list
Dictionaries The 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
Creating a Dictionary To 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.
Membership Operation The membership operator in checks if the key is present in the dictionary and returns True, else it returns False.
Dictionaries are Mutable which implies that the contents of the dictionary can be changed after it has been created.
Built in functions len() Returns the length or number of key: value pairs of the dictionary passed as the argument
dict() Creates a dictionary from a sequence of key-value pairs
keys() Returns a list of keys in the dictionary
values() Returns a list of values in the dictionary
items() Returns a list of tuples (key —value) pair
get() Returns the value corresponding to the key passed as the argument If the key is not present in the dictionary it will return None
update() appends the key-value pair of the dictionary passed as the argument to the key-value pair of the given dictionary
clear() Deletes or clear all the items of the dictionary
del() Deletes the item with the given key .To delete the dictionary from the memory we write: del Dict_name
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Oktoberfest
max.grassl
Stilmittel
Cassibodua
ICD-10 - F-Diagnosen
monsteralarm
Globalization – global challenges
ExamTime Bewerter
Flipped Classroom Modell
Laura Overhoff
Euro-FH // Zusammenfassung SOPS3
Robert Paul
Vetie - Radiologie 2017
Fioras Hu
THEO: POLKO Sophie Lecheler SS19
anna Meyer
Vetie Reprospaß
Tropsi B
Vetie Milchhygiene 2018
Theresa Blaue
Vetie - Lebensmittel 2022
Ann Borg