Python Basics #1: Hello World
Welcome to the exciting and powerful world of Python. If you’re here, you probably have at least one of these Excel files in your life:
- The too big for its own good: This Excel file has so much data in it that it takes 10 minutes to open and another 10 minutes every time you have to edit it. It was probably designed a few years ago and now you are in charge of managing it.
- The repetitive report: This Excel report is important for you and your team. So important, in fact, that you refresh the report each week or month. This routine, manual updating of the report eats up valuable time.
Mito is designed to help you leverage your Excel skills to automate these Excel reports using Python. Since the Mito spreadsheet generates the equivalent Python code for every edit you make, you don’t need to spend the next few months learning Python and Stack Overflow won’t become your most visited website.
But even though Mito handles the bulk of the programming for you, its helpful to understand a few basic principles of Python and Jupyter. They'll help you understand what’s going on and make the most of your Python script. That's what this series focusses on – teaching you the bare minimum Python and Jupyter you need to know to be successful using Mito to automate Excel reports.
Jupyter notebooks are the go-to tool for Python data analytics. A notebook is where you'll write code and access the Mito spreadsheet.
Jupyter notebooks are made up of individual code cells. In the picture above, there are two code cells each containing some Python code. You can think of each cell as a separate "chunk" of code that you can run and edit independently.
Let’s write and execute our first piece of code. In a Jupyter code cell, we'll write code that prints the message "Hello World" to welcome ourselves to the world of Python automation.
To execute code in Jupyter, select the code cell and press
Enter. If we did it correctly:
- The words “Hello World” should be printed below the code cell
- The code cell execution number should have increased by 1.
You can think of executing code like this: in Excel, you write a formula in a cell and press
Enter to apply that formula. In Jupyter, you write code in a cell and press
Enter to execute that code. Just like in Excel, you can modify the code and run it again to get updated results.
In the next post in this series, we'll look at how variables can make our code more flexible.