Module 5 - For Loop and Dictionary
Module 5 - For Loop and Dictionary
Dictionary and
For Loop
Module 5
1
Click to edit Master title style
Outline:
• Dictionary
• For Loop
2
Click to Dictionary
Python edit Master title style
3
Click to Dictionary
Python edit Master title style
4
Clickdict()
The to edit Master title
Constructor style
Method
5
Click to edit
Accessing Master title style
Dictionary
6
Click to edit
Dictionary MasterDelete,
Update, title style
Retrieve, and Check
7
Click to edit
Dictionary MasterDelete,
Update, title style
Retrieve, and Check
8
Click to edit Master title style
Built-in
Dictionary
Methods
9
Click to edit[14]
Simulation Master title style
10
Click to For
Python editLoop
Master title style
• The body of the for loop is executed for each member element in
the sequence
• Hence, it doesn't require explicit verification of a boolean expression
controlling the loop (as in the while loop)
11
Click
For to edit
Loop Master title style
Syntax
12
Click
For to edit
Loop withMaster title style
the range() Function
13
Click
For to edit
Loop Master
Exit, title Else
Continue, styleBlock, and Nested
• The execution of the for loop can be stop and exit using the break
keyword on some condition
• Use the continue keyword to skip the current execution and
continue on the next iteration using the continue keyword on some
condition
• The else block can follow the for loop, which will be executed when
the for loop ends
• If a loop (for loop or while loop) contains another loop in its body
block, we say that the two loops are nested
• If the outer loop is designed to perform m iterations and the inner loop is
designed to perform n repetitions, the body block of the inner loop will get
executed m X n times
14
Click to edit[15]
Simulation Master title style
15