Viewers: in countries Watching now:
Due to its power, simplicity, and complete object model, Python has become the scripting language of choice for many large organizations, including Google, Yahoo, and IBM. In Python 3 Essential Training, Bill Weinman demonstrates how to use Python 3 to create well-designed scripts and maintain existing projects. This course covers the basics of the language syntax and usage, as well as advanced features such as objects, generators, and exceptions. Example projects include a normalized database interface and a complete working CRUD application. Exercise files accompany the course.
One other type of conditional structure in Python is the conditional expression. Let's make a working copy of conditionals.py, conditionals-working.py and we'll open up that working copy, and we'll go ahead and assign a couple of variables. Now, a lot of times, all you're doing with a conditional is something like this. if a is less than b, then V equals this is true, else, V equals this is not true and print v.
You'll see this kind of a thing a lot in a lot of different languages. We save that and run it, say this is true, and if the condition is otherwise, save and run. It says this is not true. So, in Python, there's a much, much easier way to do this. You can simply say v equals this is true if a is less than b, else, this is not true, And so that takes all of this, and it basically puts it in an expression.
So delete that, and I save and run, and we get exactly the same results. Make that a 0 and it'll say this is true, and this is true. So, all we've done here is we've taken that whole if-else structure and we put it in an expression. And Python has several of these, and we'll cover these throughout the course, but it's a convenient shorthand, and you'll notice that it even reads well. v equals this is true if a is less than b, else, this is not true And so this part here is what makes it a conditional expression.
You have if, and you have the expression that evaluates true or false, and else, and then a second value. So, without all of this, you would simply have v equals this is true, and with all of this, you have a conditional expression, this is true or this is not true, depending on the evaluation of this conditional expression. So, that's a conditional expression in Python, and it's a very convenient shorthand for a lot of cases where you would otherwise use four lines of if and else.
Find answers to the most frequently asked questions about Python 3 Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.