Let’s Start :
Addition Of N Numbers
Program to Calculate the sum of N inputs of from the user:
Conditional branching is used to make the system execute one set of statements and skip another set of statements, based on a
In Python conditional branching is done using the “if”- “elif” — “else” statement.
if statement is used for conditional branching of program code.
- A criteria
- A block of code associated with it
System evaluates the criteria and results into a boolean. When the boolean value is True then the associated block of code executes, otherwise not.
Optionally as “if” statement has:
- An “elif” statement
- An “else” statement
An elif statement represents a secondary criteria based on the “FALSE” state of a primary criteria represented using an “if” or an “elif” statement.
System evaluates an “elif” only when the criteria that precede it is “FALSE”.
On evaluation if its (elif) result is “TRUE” then its (elif) block of code executes, otherwise not. else statement is optionally associated with elif.
else statement is optionally associated with an “if” statement or an “elif” statement.
It (else) is associated with the FALSE state of the proceeding condition. Hence it executes only when the proceeding criteria evaluates to false.
Program a Basic Arithmetic Calculator