This document provides an overview of Python data structures, specifically lists. It defines data structures as ways of storing data to make operations more efficient. It describes built-in and user-defined data structures, and focuses on lists as a general Python data structure that allows ordered sequences of mixed data types. Key characteristics of lists include mutability, indexing, slicing, and built-in methods for sorting, appending, and other operations. The document contrasts lists with the immutable string data type.
Series of presentations from the MantraVision 2015 Event held on October 21st by Mantralogix Inc.
http://insights.mantralogix.com/mantravision-2015-event
Series of presentations from the MantraVision 2015 Event held on October 21st by Mantralogix Inc.
http://insights.mantralogix.com/mantravision-2015-event
Data processing is an integral part of most modern software development. Understanding of Abstract Algebra and Category theory will be beneficial for addressing data processing concerns.
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
Textbook Solutions refer https://pythonxiisolutions.blogspot.com/
Practical's Solutions refer https://prippython12.blogspot.com/
Contiguous memory locations are occupied to store data in memory, this structure of storing data is Array.
Introduction to Lists
Elementary Data Representation Different data structures, Operations on Data structures.
Data processing is an integral part of most modern software development. Understanding of Abstract Algebra and Category theory will be beneficial for addressing data processing concerns.
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
Textbook Solutions refer https://pythonxiisolutions.blogspot.com/
Practical's Solutions refer https://prippython12.blogspot.com/
Contiguous memory locations are occupied to store data in memory, this structure of storing data is Array.
Introduction to Lists
Elementary Data Representation Different data structures, Operations on Data structures.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Digital Tools and AI for Teaching Learning and Research
Lists and Tuples
1. DATA STRUCTURES:
• DATA STRUCTURES ARE PARTICULAR WAYS OF STORING DATA TO
MAKE SOME OPERATION EASIER OR MORE EFFICIENT. THAT IS,
THEY ARE TUNED FOR CERTAIN TASKS
• DATA STRUCTURES ARE SUITED TO SOLVING CERTAIN PROBLEMS,
AND THEY ARE OFTEN ASSOCIATED WITH ALGORITHMS.
ROUGHLY TWO KINDS OF DATA STRUCTURES:
• BUILT-IN DATA STRUCTURES, DATA STRUCTURES THAT ARE SO
COMMON AS TO BE PROVIDED BY DEFAULT
• USER-DEFINED DATA STRUCTURES (CLASSES IN OBJECT ORIENTED
PROGRAMMING) THAT ARE DESIGNED FOR A PARTICULAR TASK
2. THE PYTHON LIST DATA STRUCTURE
• PYTHON COMES WITH A GENERAL SET OF BUILT IN DATA
STRUCTURES:
• LISTS
• TUPLES
• STRING
• DICTIONARIES
• SETS
• OTHERS...
• A LIST IS AN ORDERED SEQUENCE OF ITEMS.
• YOU HAVE SEEN SUCH A SEQUENCE BEFORE IN A STRING. A
STRING IS JUST A PARTICULAR KIND OF LIST
4. SIMILARITIES WITH STRINGS
• CONCATENATE/+ (BUT ONLY OF LISTS)
• REPEAT/*
• INDEXING (THE [ ] OPERATOR)
• SLICING ([:])
• MEMBERSHIP (THE IN OPERATOR)
• LEN (THE LENGTH OPERATOR)
5. OPERATORS
[1, 2, 3] + [4] [1, 2, 3, 4]
[1, 2, 3] * 2 [1, 2, 3, 1, 2, 3]
1 IN [1, 2, 3] TRUE
[1, 2, 3] < [1, 2, 4] TRUE
COMPARE INDEX TO INDEX, FIRST DIFFERENCE DETERMINES THE
RESULT
6. DIFFERENCES BETWEEN LISTS AND
STRINGS
• LISTS CAN CONTAIN A MIXTURE OF
ANY PYTHON OBJECT, STRINGS CAN
ONLY HOLD CHARACTERS
• 1,"BILL",1.2345, TRUE
• LISTS ARE MUTABLE, THEIR VALUES
CAN BE CHANGED, WHILE STRINGS
ARE IMMUTABLE
• LISTS ARE DESIGNATED WITH [ ],
WITH ELEMENTS SEPARATED BY
COMMAS, STRINGS USE " " OR ' '
7. INDEXING
• CAN BE A LITTLE CONFUSING, WHAT DOES THE [ ] MEAN, A LIST OR
AN INDEX?
[1, 2, 3][1] 2
• CONTEXT SOLVES THE PROBLEM. INDEX ALWAYS COMES AT THE
END OF AN EXPRESSION, AND IS PRECEDED BY SOMETHING (A
VARIABLE, A SEQUENCE)
8. LIST OF LISTS
MY_LIST = ['A', [1, 2, 3], 'Z']
• WHAT IS THE SECOND ELEMENT (INDEX 1) OF THAT LIST? ANOTHER LIST.
MY_LIST[1][0] # APPLY LEFT TO RIGHT
MY_LIST[1] [1, 2, 3]
[1, 2, 3][0] 1
9. LIST FUNCTIONS
• LEN(LST): NUMBER OF ELEMENTS IN LIST (TOP LEVEL).
LEN([1, [1, 2], 3]) 3
• MIN(LST): SMALLEST ELEMENT. MUST ALL BE THE SAME
TYPE!
• MAX(LST): LARGEST ELEMENT, AGAIN ALL MUST BE THE
SAME TYPE
• SUM(LST): SUM OF THE ELEMENTS, NUMERIC ONLY
11. CHANGE AN OBJECT'S CONTENTS
• STRINGS ARE IMMUTABLE. ONCE CREATED, THE OBJECT'S CONTENTS CANNOT
BE CHANGED. NEW OBJECTS CAN BE CREATED TO REFLECT A CHANGE, BUT THE
OBJECT ITSELF CANNOT BE CHANGED
MY_STR = 'ABC'
MY_STR[0] = 'Z' # CANNOT DO!
# INSTEAD, MAKE NEW STR
NEW_STR = MY_STR.REPLACE('A','Z')
12. LISTS ARE MUTABLE
UNLIKE STRINGS, LISTS ARE MUTABLE. YOU CAN CHANGE THE
OBJECT'S CONTENTS!
MY_LIST = [1, 2, 3]
MY_LIST[0] = 127
PRINT(MY_LIST) [127, 2, 3]
13. LIST METHODS
• REMEMBER, A FUNCTION IS A SMALL PROGRAM (SUCH AS
LEN) THAT TAKES SOME ARGUMENTS, THE STUFF IN THE
PARENTHESIS, AND RETURNS SOME VALUE
• A METHOD IS A FUNCTION CALLED IN A SPECIAL WAY,
THE DOT CALL. IT IS CALLED IN THE CONTEXT OF AN
OBJECT (OR A VARIABLE ASSOCIATED WITH AN OBJECT)
14. AGAIN, LISTS HAVE METHODS
MY_LIST = ['A',1,TRUE]
MY_LIST.APPEND('Z')
the object that
we are calling the
method with
the name of
the method
arguments to
the method
15. SOME NEW METHODS
• A LIST IS MUTABLE AND CAN CHANGE:
• MY_LIST[0]='A' #INDEX ASSIGNMENT
• MY_LIST.APPEND()
• MY_LIST.EXTEND()
• MY_LIST.POP()
• MY_LIST.INSERT()
• MY_LIST.REMOVE()
• MY_LIST.SORT()
• MY_LIST.REVERSE()
16. MORE ABOUT LIST METHODS
• MOST OF THESE METHODS DO NOT RETURN A VALUE
• THIS IS BECAUSE LISTS ARE MUTABLE, SO THE METHODS
MODIFY THE LIST DIRECTLY. NO NEED TO RETURN
ANYTHING.
• CAN BE CONFUSING
17. UNUSUAL RESULTS
MY_LIST = [4, 7, 1, 2]
MY_LIST = MY_LIST.SORT()
MY_LIST NONE # WHAT HAPPENED?
WHAT HAPPENED DID THE SORT OPERATION CHANGED THE
ORDER OF THE LIST IN PLACE (RIGHT SIDE OF ASSIGNMENT).
THEN THE SORT METHOD RETURNED NONE, WHICH WAS
ASSIGNED TO THE VARIABLE. THE LIST WAS LOST AND NONE IS
NOW THE VALUE OF THE VARIABLE.
18. RANGE
• WE HAVE SEEN THE RANGE FUNCTION BEFORE. IT
GENERATES A SEQUENCE OF INTEGERS.
• IN FACT WHAT IT GENERATES IS A LIST WITH THAT
SEQUENCE:
MYLIST = RANGE(1,5)
MYLIST IS [1,2,3,4]
19. SPLIT
• THE STRING METHOD SPLIT GENERATES A SEQUENCE OF
CHARACTERS BY SPLITTING THE STRING AT CERTAIN SPLIT-
CHARACTERS.
• IT RETURNS A LIST (WE DIDN'T MENTION THAT BEFORE)
SPLIT_LIST = 'THIS IS A TEST'.SPLIT()
SPLIT_LIST
['THIS', 'IS', 'A', 'TEST']
20. SORTING
ONLY LISTS HAVE A BUILT IN SORTING METHOD. THUS YOU OFTEN CONVERT YOUR
DATA TO A LIST IF IT NEEDS SORTING
MY_LIST = LIST('XYZABC')
MY_LIST ['X','Y','Z','A','B','C']
MY_LIST.SORT() # NO RETURN
MY_LIST
['A', 'B', 'C', 'X', 'Y', 'Z']
21. REVERSE WORDS IN A STRING
JOIN METHOD OF STRING PLACES THE CALLING STRING
BETWEEN EVERY ELEMENT OF A LIST
22. SORTED FUNCTION
THE SORTED FUNCTION WILL BREAK A SEQUENCE INTO
ELEMENTS AND SORT THE SEQUENCE, PLACING THE RESULTS
IN A LIST
SORT_LIST = SORTED('HI MOM')
SORT_LIST
[‘ ’,'H','I','M','M','O']
24. LISTS AND TUPLE
• EVERYTHING THAT WORKS WITH A LIST WORKS WITH A
TUPLE EXCEPT METHODS THAT MODIFY THE TUPLE
• THUS INDEXING, SLICING, LEN, PRINT ALL WORK AS
EXPECTED
• HOWEVER, NONE OF THE MUTABLE METHODS WORK:
APPEND, EXTEND, DEL
25. COMMAS MAKE A TUPLE
FOR TUPLES, YOU CAN THINK OF A COMMA AS THE OPERATOR
THAT MAKES A TUPLE, WHERE THE ( ) SIMPLY ACTS AS A
GROUPING:
MYTUPLE = 1,2 # CREATES (1,2)
MYTUPLE = (1,) # CREATES (1)
MYTUPLE = (1) # CREATES 1 NOT (1)
MYTUPLE = 1, # CREATES (1)
26. MULTIPLE COLLECTS
[X+Y FOR X IN RANGE(1,4) FOR Y IN RANGE (1,4)]
IT IS AS IF WE HAD DONE THE FOLLOWING:
MY_LIST = [ ]
FOR X IN RANGE (1,4):
FOR Y IN RANGE (1,4):
MY_LIST.APPEND(X+Y)
[2,3,4,3,4,5,4,5,6]