New Training: Basic Input and Output with Python
In this 7-video skill, CBT Nuggets trainer Ben Finkel teaches you how to get data into and out of your programs, how to use the print() function, how to use the input() function, and how to format text output. Watch this new Python training.
Learn Programming and Development with one of these courses:
This training includes:
- 7 videos
- 50 minutes of training
You’ll learn these topics in this skill:
- Basic Input and Output
- Output with Print
- Print Parameters Sep, End, and File
- Getting data with Input
- Using fileinput to Read Files
- Formatting Text Output
- Putting Input and Output to Use
What Are Python Logical Operators?
All programming languages have their own syntax or structure in which the way commands tell the code what to do. Despite the variations in these syntaxes, all programming languages still depend on basic concepts such as:
- Arithmetic operators
- Logical operators
- Relational operators
- Bitwise operators
Let's take a quick look at logical operators.
Logical operators are the AND, OR, and NOT operators. They are typically used with comparison operators but are not restricted to that.
For instance, a logical operator could be used with an IF statement where you need to compare values of two different variables, then perform an action if those requirements are met.
If (X == 0 AND Y==0) Then doSomeThings
In this case, both X and Y need to equal 0 for that IF statement to be true. If only one value needs to meet that criteria, you could use the OR operator instead. Likewise, if you need to perform an operation if X is equal to any value but 0, you could use the NOT operator.