Flash Cards -Lists

Description

Flashcards on Flash Cards -Lists, created by Aparna Dhirde on 03/17/2020.
Aparna Dhirde
Flashcards by Aparna Dhirde, updated more than 1 year ago
Aparna Dhirde
Created by Aparna Dhirde over 4 years ago
16
0

Resource summary

Question Answer
Lists A list is a data structure in Python that is mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a list is called an item. Lists are defined by having values between square brackets [ ]
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
Concatenation Allows us to join two or more lists using concatenation operator depicted by the symbol +.
Repetition Allows us to replicate a list using repetition operator depicted by symbol *.
Membership membership operators in checks if the element is present in the list and returns True, else returns False.
Slicing Slicing is used to extract a part of the list.
Built-in Functions built-in 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 The single element can also be a list
extend() Appends each element of the list passed as argument to 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
index() 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 parameter to this function and also removes it from the list. If no parameter is given, then it returns and removes the last element of the list
reverse() Reverses the order of elements in the given list
sorted() It takes a list as parameter and creates a new list consisting of the same elements arranged in sorted 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
sort() Sorts the elements of the given list in-place
Nested Lists When a list appears as an element of another list, it is called a nested list.
Show full summary Hide full summary

Similar

Periodicity
hanalou
AQA GCSE Physics Unit 2.2
Matthew T
Themes in Lord of the Flies
lowri_luxton
The Biological basis of Heart Disease
Andrea Leyden
Coastal Landscapes
Chima Power
A-level Maths: Key Differention Formulae
Andrea Leyden
Animal Farm Chapter Overview
10jgorman
GCSE French - Parts of the Body
Abby B
Edexcel Additional Science Biology Topic 1- Genes and Enzymes
hchen8nrd
GCSE REVISION TIMETABLE
Joana Santos9567
“In gaining knowledge, each area of knowledge uses a network of ways of knowing.” Discuss this statement with reference to two areas of knowledge
Julianapabab