This post focuses on setting up: Python 3, PyCharm, and your first script. R in the next one.
Table of Contents
Introduction
Downloading & Installing Python
Downloading & Installing Pycharm
Setting Things Up
Running a Python Script
Your First Python Function
1 - Introduction
Welcome to the first post that is focused on the coding section. I will be making the linear algebra, and the statistics post separate from this. It’ll look strange on why we are learning 3 completely different topics. But closer to you end, you’ll see how they all connect with each other.
Recall, from the introduction post, I said that you will need to learn: R, Python, and SQL. We don’t need to worry about SQL right now, so let’s focus on the other 2.
Nowadays, everyone uses Python 3, very few organizations use Python 2 (they still exist though). To maximize job prospects, we’ll focus on Python 3.
2 - Downloading & Installing Python
The direct link to download Python3 is located here: (*LINK*). You can install it like any piece of software. For those that prefer to follow a video: you can follow this video alongside to install Python 3:
If done properly, when you open up something called Integrated Development & Learning Environment (IDLE) from your computer, you’ll see something that looks like this:
3 - Downloading & Installing PyCharm
From the above, you can see that the above is some 1980s boomer looking UI. Still better than curve.fi though. We want to use a software, that links to the python installed on our machine, but makes things look a lot prettier. Nowadays, most people that code in Python use a software called PyCharm. You can download PyCharm Here (*Link*).
Think about it as Python3 being the back end that runs all the code. But PyCharm being the front end that looks all pretty for the human user. For those that prefer videos, you watch and follow this along:
Once you’ve installed Python 3 to your computer, make sure you remember where you installed it. We will need this information later.
4 - Setting Things Up
First, let’s link the 2 together, then let’s build our first program in Python, and introduce you guys to your very first function.
1.) Open up PyCharm → Create a New Project → untitled, and save it wherever you wish.
The above will create a new python project, anytime you open up PyCharm, it will automatically open up the above project you made, unless you specify it otherwise.
2.) File → Settings → Project: untitled → Project Interpreter. Click on the top right that looks like a cog wheel
3.) After the cog wheel, click on add. Now navigate to where you installed the above Python 3, and voila you have now synced the 2 together.
4.) Now, from the left side, click on the folder that has your project. Then click on File → New → Python File. Now, name this python file to whatever you like, and we are now officially good to go.
5 - Running A Python Script
To run a script in PyCharm, we will need to:
1.) Click on Run (at the top) —> Run… → now click on the python file you made.
2.) If you work in the field of Data Science, you will want to track several of the variables you’ve made. You’ll also want to work a little bit with the shell. To enable the 2 to work together, do:
3.) Click on Run (at the top) —> Edit Configuration —> Click the checkbox so that it says Run With Python Console
To actually run it, just click on run at the top in the menu, then click on run from the dropdown, then select the python file you just created.
6 - Your First Python Function
In Python, before we can get any sort of output, we need to use a function called print(). If we do not use the print function, we will not get any output. To actually use the print function, we will need to encapsulate what we want to display in parentheses.
For example:
print(1+2)
print(7+9)
print(7*3)
All of the above will produce an output. But… none of the below will produce an output.
For example:
1+2
7+9
7*3
None of the above will produce any output because it does not have the print().
Here’s what it’d look like in PyCharm:
Working through this, I got a couple questions:
How important is it to have mastery of something like pycharm or anaconda or github?
Should I be going through tutorials/training?
Would I embarrass myself if I didn't know all the ins and outs of these tools in an interview?
And thank you for creating this substack. I am trying to pivot from a career as a pharma scientist to something data related and I find it very interesting.