Python is a highly popular programming language. It is so popular that it is now the most commonly used programming language for machine learning/data science purposes having surpassed R.
However, Python is not limited to just statistical tools. Python is also used by many companies for a host of reasons including Yahoo, Dropbox, Google, NASA, IBM, and Mozilla.
One secret to Pythons popular is its flexibility. When using Python it is possible to employ several different coding styles. Below is just some of them.
- Procedural: This is the simplest form of coding and involves executing each line of code sequential.
- Functional: Functions are used to transform data as found in mathematics.
- Imperative: Employs statements to achieve a goal
- Object-oriented: The use of objects (aka data structures) to model the real world. Not fully implemented in Python.
You can mix these styles together to make powerful applications.
You can download Python by searching for “Anaconda Python” in Google. The Anaconda version of Python downloads several additional features to besides Python including the Spyder IDE which is what we will use here.
Once you download and install Anaconda, on your computer you need to search for the program called “SPyder”. When you open it you will see the following.
Here is what each pane represents.
- To the left is the text editor, you can type code that you want to save here.
- In the top right is the variable explorer. Here you can find a list of the objects you have made.
- In the bottom right is the Interactive Python console or “IPython” console for short. Here you can type code quickly without the need of storing it for long-term use. In addition, the results of any code execution is normally displayed here as well
When writing code remember that you can save it long term in the text editor or just execute it quickly in the console,
First Line of Code
We will now run our first line of code. Followed by the output in the IPython Console. Below is what we typed into the Console
print("Hello to Python")
Here is what it looks like in the console
Here is what we did.
- We typed “print(“Hello to Python”)” into the console. This is an example of the use of a function.
- The output provides several pieces of information.
- The blue shows what line this is in the console. In other words, this is the third line of code I had typed in the console. You may have a different number.
- The purple is the function being used which for us is the “print” function which simply displays the input
- The green is the argument that the function is changing. Our argument is a string of text that is put in quotes deliberately
- The text in black is the actual output
Of course, there is much more to Python then this. However, this serves as an introduction for a future post.
Python is a popular programming language used in a variety of application. The source of its popularity has to do with it general-purpose philosophy. There’s a little bit of something for everybody in this language which encourages its use. Using the Spyder IDE will allow you to experience Python for the purpose of acquiring new skills.