Data storage, Control Structures and Operators Logical Operators
Decisions
Decision making is anticipation of conditions occurring
while execution of the program and specifying actions
taken according to the conditions.
Decision structures evaluate multiple expressions which
produce TRUE or FALSE as outcome. You need to
determine which action to take and which statements to
execute if outcome is TRUE or FALSE otherwise.
Conditional Statements
Operators if <expr>:
Arithmetic Operators <statement>
if <expr>:
<statement>
<statement>
...
<statement>
<following_statement>
if <expr>:
<statement(s)>
else:
<statement(s)>
Loops / Iteration
Most useful and powerful structure
Allows the repetition of instructions or statements in the
Comparison Operators loop body
Parts of the iteration structure
Loop body instruction(s) or statements which are
repeated Loop-exit condition the condition to be tested
Assignment Operators
before each repetition
Types
while loop
for loop
o In
o Range
Break Statements
Force immediate termination of a loop,
bypassing the conditional expression and any
remaining code in the body of the loop
The loop is terminated and program control
resumes at the next statement following the
loop
Pass Statements
The pass statement is a null operation; nothing happens
when it executes. The pass is also useful in places where
your code will eventually go, but has not been written yet
Continue Statements
In loops, a continue statement cause control to be
transferred directly to the conditional expression that
controls the loop
Lists
The list is a most versatile data type available in Python
which can be written as a list of comma-separated values
(items) between square brackets.
numbers= [1, 2, 3, 4, 5 ];
food = ["cake", "burger", "fries"]
print(numbers[index number])
print(numbers[0]) #1
print(food[1]) #burger