03 Python Programming Basics Part II
03 Python Programming Basics Part II
Basics Part II
By:
Sanka Sandamal
Decision Making
- Decision-making is the anticipation of
conditions occurring during the execution
of a program and specified actions taken
according to the conditions.
- Decision structures evaluate multiple
expressions, which produce TRUE or
FALSE as the outcome. You need to
determine which action to take and
which statements to execute if the
outcome is TRUE or FALSE otherwise.
‘break’ Statement
- The break statement is used for premature termination of the current
loop.
- After abandoning the loop, execution at the next statement is resumed.
- The break statement can be used in both while and for loops.
Defining a Function
- Function blocks begin with the keyword ‘def’ followed by the function
name and parentheses ( ( ) ).
- Any input parameters or arguments should be placed within these
parentheses. You can also define parameters inside these parentheses.
- The code block within every function starts with a colon (:) and is
indented.
- rb
Opens a file for reading only in binary format.
- r+
Opens a file for both reading and writing.
- rb+
Opens a file for both reading and writing in binary format.
- W
Opens a file for writing only. Overwrites the file if the file exists.
- w+
Opens a file for both writing and reading.
- wb+
Opens a file for both writing and reading in binary format.
- a
Opens a file for appending.
- ab
Opens a file for appending in binary format.
- ab+
Opens a file for both appending and reading in binary format.
Thank You.
By:
Sanka Sandamal