Learn your way! Get started

Python 3, Part 2 of 6: Statements

with expert Peter Thorsteinson


Watch trailer


Course at a glance

Included in these subscriptions:

  • Dev & IT Pro Video
  • Dev & IT Pro Power Pack

Release date 7/29/2014
Level Beginner
Runtime 1h 34m
Closed captioning Included
Transcript Included
eBooks / courseware Included
Hands-on labs N/A
Sample code Included
Exams Included


Enterprise Solutions

Need reporting, custom learning tracks, or SCORM? Learn More



Course description

In this course we are going to take a look at statements and how they fit within the overall program structure. Then we'll take a look at the ‘if’ statement and we'll see how that is used to make decisions. Then we will take a look at looping constructs and how the ‘for’ keyword can be used to iterate over the elements within a sequence. Next we’ll take a look at how the ‘while’ keyword can be used to iterate a loop as long as a Boolean expression remains true. Next are ‘continue’ and ‘break’, we'll see how they can be used to change the normal course of action and the normal flow of a looping construct to either continue back to the top or to break out and continue beyond the end of the loop. Then we'll take a look at the exec function which can be used to execute arbitrary code that is in the form of a string. Then we'll take a look at exception handling, how to raise an exception, and how to catch an exception for dealing with unusual circumstances, in particular dealing with error type situations.

Prerequisites

This course teaches anyone who is interested in learning the basics of programming computers using Python 3. This course has no programming language pre-requisites and only assumes the basic familiarity with computer usage that virtually everybody has. Anyone with moderate computer end-user experience should be able to take this course.

Learning Paths

This course is part of the following LearnNowOnline SuccessPaths™:
Python Development

Meet the expert

Peter Thorsteinson has been working for two decades in many areas of Microsoft-based software development technologies, including all the latest languages, frameworks, and tools. He has been involved in several large scale software development projects and has authored and co-authored several books and courses relating to ASP.NET, AJAX, JavaScript, WPF, WCF, WF, ADO.NET, and LINQ. Peter is currently focusing on ASP.NET MVC, jQuery, Task Parallel Library, Windows Azure, and SharePoint Development.

Course outline



Statements

If Elif Else (30:32)
  • Introduction (00:26)
  • Statements (04:31)
  • Program Structure (02:23)
  • More on Statements (01:21)
  • The if Statement (03:08)
  • The if-else Statement (00:16)
  • The if-elif-else Statement (02:03)
  • Demo: if statement (03:04)
  • Demo: Code example (03:58)
  • Demo: Short Circuit (05:21)
  • Demo: Expressions (03:43)
  • Summary (00:14)
For (11:07)
  • Introduction (00:24)
  • The for Statement (00:50)
  • The range Function (00:44)
  • The break Keyword (for Loop) (02:00)
  • The continue Keyword (for Loop) (00:59)
  • Demo: The for Loop (02:44)
  • Demo: The for – else Loop (03:12)
  • Summary (00:10)
Loops (20:12)
  • Introduction (00:34)
  • The while Statement (01:35)
  • The break Keyword (while Loop) (01:26)
  • The continue Keyword (while) (01:07)
  • Demo: The while Statement (02:43)
  • Demo: The while Output (03:47)
  • Demo: Keyword break & continue (03:38)
  • Demo: The b & c - output (02:22)
  • Demo: Loops - recap (02:45)
  • Summary (00:11)
Exec (04:32)
  • Introduction (00:29)
  • The exec Function (02:00)
  • Demo: The exec Function (01:42)
  • Summary (00:21)
Iterable (10:20)
  • Introduction (00:25)
  • Iterable Objects (02:11)
  • Demo: Iterable Objects (03:37)
  • Demo: Iterable Class (03:45)
  • Summary (00:19)
Exceptions (18:00)
  • Introduction (00:58)
  • Handling Exceptions (01:57)
  • Raising Exceptions (02:37)
  • Demo: Raising Exceptions (03:13)
  • Demo: More Exceptions 1 (05:11)
  • Demo: More Exceptions 2 (03:34)
  • Summary (00:26)