python – making decisions

Post on 06-Jan-2016

34 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Python – Making Decisions. Lecture 02. Control Structures. A program that only has one flow is useful but limited. We can use if statements to make these decisions. If - Syntax. if (condition): indented code block. Comparison Operators. Equal to Greater than Less than - PowerPoint PPT Presentation

TRANSCRIPT

Python – Making Decisions

Lecture 02

Control StructuresA program that only has one flow is useful but limited. We can use if statements to make these decisions

If - Syntaxif (condition):

indented code block

Comparison OperatorsEqual toGreater than Less thanGreater than or equal toLess than or equal toNot equal to

==><>=<=!=

Else- SyntaxWhat if you want something to happen when the if condition is false?

If Else - Example

Checking for Multiple Conditions

We use an elif statement to check multiple conditions.

Elif - Example

Logic OperatorsCheck for multiple conditions in the same keyword.There are only three: and, or, not.

Precedence

You asleep yet?

Logic Example

top related