Professional Documents
Culture Documents
Unit 9.2 For ET
Unit 9.2 For ET
Python
What is Python?
Python Data Structure
An array is a data structure which holds a set of
data items of the same data type. In a program,
an array has a name, length (representing the
number of data items to be stored) and a data
type defined by the programmer.
Using lists in Python
(1 , len(mylist))
* Start with index position 1 because we will start comparing from
2nd item of the list
mylist = [16,3,4,7,1,9]
Sorted Unsorted
Insertion Sort coding
mylist = [16,3,4,7,1,9]
for index in range(1 , len(mylist)):
pos = index
while mylist[pos -1] > mylist[pos] and pos >0:
mylist[pos -1], mylist[pos] = mylist[pos], mylist[pos -1]
pos -= 1
print(mylist)
Activity
• Go to play.blooket.com
• Enter Game ID as shown on the screen