0% found this document useful (0 votes)
27 views2 pages

Data Storage, Control Structures and Operators Decisions

Decision making in programs involves anticipating conditions and specifying actions based on whether expressions evaluate to True or False. Conditional statements like if-else and loops allow repeating instructions. If statements execute code if an expression is True or False, while loops continuously check conditions. Loops have a body, condition, and can be while or for loops iterating over a range. Break and continue statements control loop execution, and pass is a null operation. Lists are a versatile data type that store comma-separated values in brackets and allow accessing items by index.

Uploaded by

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

Data Storage, Control Structures and Operators Decisions

Decision making in programs involves anticipating conditions and specifying actions based on whether expressions evaluate to True or False. Conditional statements like if-else and loops allow repeating instructions. If statements execute code if an expression is True or False, while loops continuously check conditions. Loops have a body, condition, and can be while or for loops iterating over a range. Break and continue statements control loop execution, and pass is a null operation. Lists are a versatile data type that store comma-separated values in brackets and allow accessing items by index.

Uploaded by

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

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

You might also like