Coffing Data Warehousing Software

Understanding Advanced Python Part 2

This post is the second part of a series on Advanced Python. In this series, we’ll take what we learned in our Understanding Python Basic series (Part One of that series found here) and expand on it to understand the more challenging parts of Python. In Part 2, you’ll be learning about Conditions in Python.

If you want to use the Nexus as your Python editor, then you will find instructions at the end of the blog on how to set this up!

Tera Tom here! Welcome to Part 2 of our lesson on Advanced Python! Before we begin with our lesson on Conditions in Python, let’s make sure you have everything you need to follow along with this lesson. If you have a Python editor you want to use then you are all ready to go, but if you want an easy way to try these examples and more then go to www.CoffingDW.com and download the Nexus.  Once you have it installed just look at the picture below and see where the Python editor of Nexus exists.  If you want to install Python so you can practice with Nexus then go to the last page of this blog for detailed instructions.

Conditionals If, Else Elif  

Conditionals use if, elif, and else to give Python programmers the ability to use logic.  Notice that in our example that we are using single and double quotes to demonstrate as these are interchangeable.  Also, know that once a condition is satisfied, Python will leave and not drop down to check further conditions. In other words, the first condition met ends the condition.

An Important Point about Conditions

Once a condition is satisfied then Python will leave and not drop down to check further conditions.  In other words, the first condition met ends the conditional processing. In our example below, the age is set to 55.  In our conditional logic, the age is greater than 30 so Python prints ‘You can be a Senator’ and immediately leaves. Because the condition has been met, the elif and else statements are not even checked.

Conditionals can be Combined with And, Or and Not  

Conditionals of if, elif, and else can be checked for equal, not equal, greater than, greater than or equal, less than and less than or equal.  These conditionals and checks can be combined with the keywords of and, or and not.

Tips – Use a Simplified IF Statement  

You can verify multiple values in the simplified examples below.

Tips – Aggregation of Comparison Operators  

Aggregation of comparison operators is another nice little trick you can use.

Tips – Use of Ternary Operator for Conditional Assignment

Ternary operators are a quick way to get an if-else statement.  These are also called conditional operators.

Quiz – Ternary Operator for Conditional Assignment

Check out the Python code able and fill in the four answers.

Answer – Ternary Operator for Conditional Assignment  

Below are the answers.

How to Install and Setup Python on your Nexus

  1. Download the latest version of Nexus from our website.  https://www.coffingdw.com/nexus-trial/
  2. Once installed download Python for Windows.  https://www.python.org/downloads/windows/

Your version number can vary, but you will want to download the Windows installers. So for Python for Windows 3.7.3 located here (https://www.python.org/downloads/release/python-373/) you will select one of these highlighted links:

Note:  Nexus comes in three versions:  Nexus 64-bit, Nexus 32-bit, and Nexus WOW-64 (For 64-bit machines with 32-bit Microsoft Office installed).X86-64 can be used for the 64-bit or Wow64 version of Nexus and x86 can be used only on the 32-bit version of Nexus.

When installing, if you have the option, select “Add Python to PATH”.


If you are using an older version of Python and do not have this option, then you will need to add the path to your python executable to your PATH environment variable. Be careful when editing this variable as it can affect many Windows functionality issues. If you don’t feel comfortable about this then consult with your desktop support.

Python 3.7.3 was installed in the following directory on our PC.

C:\Users\Todd\AppData\Local\Programs\Python\Python37

You can view your Python directory by opening File Explorer and pasting in the following path:

%LocalAppData%\Programs\Python

Once you have the path to the python.exe executable then add it to your Environment PATH variable by following the direction in this link:

https://www.computerhope.com/issues/ch000549.htm

And that is how you install Python into the Nexus Query Chameleon! 

Ready for more Python training? Check out Part Three of my Understanding Advanced Python series now! Or, if you’d prefer Tera-Tom to come teach at your organization, contact our team for booking information.