Computer Science [Python]

Decision making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

An if statement consists of a Boolean / logical expression followed by one or more statements; using which, data is compared and a decision is made on the basis of the result of the comparison. The ‘if statement’ consists of a header line and a body. The header line begins with the keyword if followed by a Boolean expression and ends with a colon. if with else provides an alternative execution. An else statement contains the block of code that executes if the conditional expression in the ‘if’ statement resolves to a false value. When there are more than two possibilities in such a case more than two branches are needed. This is referred to as chained conditional. elif is an abbreviation of else if. An exception is an error that happens during execution of a program. When that error occurs, Python generates an exception that can be handled, which prevents your program from crashing. The words "try" and "except" are Python keywords and are used to catch exceptions.

To Access the full content, Please Purchase