The document discusses decision structures in Python, specifically focusing on the if statement and its use for conditional execution. It explains how to form simple conditions using relational operators and introduces the if-else statement for two-way decisions. Additionally, it highlights the importance of indentation in structuring these statements.
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 ratings0% found this document useful (0 votes)
7 views3 pages
Cits 6
The document discusses decision structures in Python, specifically focusing on the if statement and its use for conditional execution. It explains how to form simple conditions using relational operators and introduces the if-else statement for two-way decisions. Additionally, it highlights the importance of indentation in structuring these statements.
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/ 3
Lec#07: Decisions
In Python, we use the if statement to write a decision structure.
In a decision structure, a specific action is performed only if a The condition is a Boolean certain condition exists or is true The If statement expression, i.e., evaluates to provides a way to values True or False selectively execute certain statements The body is just a sequence of in a program using one or more statements conditions indented under the if heading
Forming Simple Conditions
Simple conditions that compare the value of two expressions have the following format
Boolean expressions using relational
operators
<relop> is short for
relational/comparison Relational operators operator A simple decision structure The if Statement The Logical operators;
The logical operators allow you to connect multiple conditions/
Boolean expressions to create a compound expression. Two-Way Decisions Conditional execution in an if-else statement
The if-else Statement
An if-else statement will execute one block of
statements if its condition is true, or another block if its condition is false
(Boston Studies in the Philosophy of Science 19-1) Henry Mehlberg (Auth.), Robert S. Cohen (Eds.)-Time, Causality, And the Quantum Theory_ Studies in the Philosophy of Science. Vol. 1_ Essay on the CA