Join Joe Marini for an in-depth discussion in this video Conditional structures, part of Up and Running with Python.
One of the fairly common things you run into in programming is making decisions.…Comparing values and executing code based upon whether one value is greater than, or…less than, or the same, or not the same as another one.…And that's where conditionals come into play.…In Python, conditionals are handled using the If statement and that's what we're…going to look at now. So let's start up conditionals_start.py.…And you can see here in the main function for this example, I've got two variables X…and Y. And they are 10 and 100 to start with.…
So let's go over to the example snippets.txt.…And let's copy lines 90 and 91. So we'll copy that.…And we'll paste it in down here. And you can see that what's happening is…we're comparing X to Y. And if X is less than Y, then the value of…this ST variable will be X is less than Y. And then down here we're going to copy…line 96 and we'll paste that in right here, make sure it's indented the same.…
Okay, so let's go ahead and run this and watch what happens.…So I will click Run and I choose Python Run.…
- Installing Python
- Choosing an editor/IDE
- Working with variables and expressions
- Writing loops
- Using the date, time, and datetime classes
- Reading and writing files
- Fetching Internet data
- Parsing and processing HTML
Skill Level Beginner
1. Preparing the Development Environment
2. Python Basics
3. Working with Dates and Times
4. Working with Files
5. Working with Web Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.