Follow the following steps to run Python on your computer.
- Download Thonny IDE.
- Run the installer to install Thonny on your computer.
- Go to File > New. Then save the file with .py extension. For example, hello.py, example.py etc.
- You can give any name to the file. However, the file name should end with .py
- Write Python code in the file and save it.
OR
- Although you can run Python programs via command line as well, it is typically better for beginners to use a text editor. Luckily, with the installation of Anaconda, you get the Jupyter Notebook installed as well.
- The "Jupyter Notebook" is a cloud based application that allows users to create, share, and manage their documents. We will use Jupyter to write our Python code in this article.
To open Jupyter, you can go to Start Menu and find the "Jupyter Notebook" application. You can also search for it in Applications. This is shown in the following:
Open the "Jupyter Notebook" application. It will then be opened in your default browser. For compatibility, I would recommend that you use Google Chrome as your default browser, but other browser types like Firefox would work as well.
When the application opens in your browser, you will see the following page:
On the right hand side of the page, you will see an option "New". Click that buttonand a dropdown list will appear. Select, "Python 3" from the dropdown list. This will open a brand new notebook for you, which looks like this:
Here you can easily write, save, and share your Python code.
Let's test and make sure everything is working fine. To do this, we'll create a simple program that prints a string to the screen.
Enter the following code in the text field in your Jupyter notebook (shown in the screenshot above):
print("Welcome to Python!")
The
print
does exactly what it sounds like, it simply prints some text to the screen. The text you want to display is entered within the double quotations inside the parenthesis that follow the print
keyword.
To run code in "Jupyter Notebook" just press "Ctrl + Enter". The output of the above code should look like the following:
And there you have it, we have successfully executed our first Python program! In the following sections, we'll continue to use Jupyter to teach and discuss some core Python features, starting with variables.
No comments:
Write comments