0% found this document useful (0 votes)
4 views

Data & Control Structures

Uploaded by

Giratina13luck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Data & Control Structures

Uploaded by

Giratina13luck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Data & Control

Structures
Garrison Anantham, X A
Types of Data
Structures and
What are
Control
Structures?

Topics Video
introducing
Data & Control
Structures

Total 15
minutes
Vid on introduction to python stuff
Data Structures
in Python
 Data structures are
collections of information.
 There are four types:
1) List
2) Tuple
3) Set
4) Dictionary
Lists
 As the name suggests it makes a list.
 This list is mutable, indexed and ordered
 The lists are made using ‘[]’
(E.g. List1=[“Owl”,“Ladybug”,“Duck”,“Poke”]
 Commands used in List are:
i. print(list1) (full)
ii. print(list1[0]) or print (list1[-4]) (specific)
iii. List1[1]=“Panda” (changing an item)
iv. print(len(List1)), print (List1[1:2]) (counting and a specific range of the list)
v. List1.append (“Orion”), List1.remove (“Poke”)
vi. List1.insert(0,“Yellow Dog”) List1.pop(1,“Owl”)  [‘Yellow
Dog’,‘Panda’,‘Duck’,‘Orion’]
vii. del List1[-2], del List1
Tuples
 This is like a list, but it is immutable.
 ‘()’ are used for tuples.
 Some commands:
tuple13=(“Pizzas”,“Momos”,“Tacos”)
print (tuple13)
print (tuple13 [0])
(same as list except for those that add or delete an item on the list)

Note: If you make a list with only 1 item you need to put , after it
anyways.
Also always put “” before and after each item if it is a word, this can be
disregarded if it is a number.
Sets
 This is a list which is unordered and
unidexed. That means the output is
in
a random order and you can’t view
individual items.
 They are made using ‘{}’
 Basic code:
Set01={“Dragon”,“Aries”,“Diamond”}
print (set01)
‘Diamond’,‘Dragon’,‘Aries’
Dictionaries
 They are a collection of key-value pairs separated by :.
 They are enclosed by ‘{}’.
 Example

{ }
Basic sequences loops vids stuff
Control
Structures
 A control is a block of
code which analyses
given data to decide
which result should be
obtained.
 The two forms of
control structures are:
a) If Statements (If elif
else)
b) Loop Statements (For
loop, while loop, loop
else)
If elif else statements

Input:
time = 20
if time > 6
print (“Good morning!”)
else if time > 12
print (“Good afternoon!”)
else time > 16
print (“Good Evening!”)
Loops

Input: Output:
i=0
while i<7:
0
print (i) 1
if i ==3:
2
contiue
if i==4: 3
print (“breaking from loop”) 4
break
Breaking the loop
i=i+1

You might also like