CS 100

Logo

Scientific Computing

Activity 1 - Environment Setup

Part I. Install Thonny

Thonny is a simple Python IDE (integrated development environment) that we will use to create programs written in Python and run them. Complete the following steps to install Thonny on your computer.

Click on Thonny’s homepage. In the top right box, select your operating system - Windows, Mac, or Linux - which will download the appropriate installer.

Mac installation:

Double click the downloaded .pkg file. Click ‘Continue’ a few times and agree to the terms of service. When prompted, choose the default option ‘Install for all users of this computer’. You will need to type in the password you use to log into your computer. Click ‘Continue’ until the installation finishes.

You can now access Thonny from Spotlight. To launch it, click the magnifying glass on the top right corner of your screen and start to type “Thonny”. Double click the application and select ‘Let’s Go!’

We will use this application often, so it might help for you to save it in the Dock for easy access later. Right click on the Thonny icon, select Options –> Keep in Dock.

Windows installation:

Double click on the downloaded .exe file. Click ‘Next’. When prompted, you may want to choose to create a desktop icon so that you can access it easily. The remaining default options are fine, so you can click ‘Next’ a few more times until it finishes.

You can now launch Thonny by double clicking the Thonny icon from your desktop. If you didn’t save it as an icon, you can also search for Thonny from the start menu by typing “Thonny”.

Linux installation:

In your terminal, run sudo apt-get install thonny. Type y to continue.

Part II. Hello world!

You’re now ready to write a program. Open Thonny and follow these steps:

  1. On your desktop create a folder called CS100 (yes, no spaces!). Inside that folder create three folders: ch1, ch2, and ch3. You will be saving today’s work (and all work from chapter 1) in ch1. Work done from chapter 2 of the textbook will be saved in ch2 and so on.
  2. Open Thonny. In the top part of it you will see an untitled file already opened for you.
  3. In that file type the following:
    print("Hello world!")
    
  4. Save the file (File + Save As) as hello.py in the ch1 folder you created in Step 1.
  5. Click the green arrow in Thonny to run the program. You’ll know it worked when something happens in the Command Shell (Shell Area).
  6. Change the line so that instead of Hello world! it reads Hello, Dr. Guarnera!
  7. Click the green arrow in Thonny to check it outputs what you expect.
  8. Click the X on the tab at the top of the file that’s open in the Program Area. This will close the file you created.
  9. Open the file you saved (File + Open). After the line to print Hello world, add the following lines:
    print("    *")
    print("   ***")
    print("  *****")
    print(" *******")
    
  10. Run the program and notice the result.
  11. Add a few more lines of your own. What other shapes can you make?

Congratulations, you just wrote your first Python program! 😊

How to submit

Make sure you saved your work and that it runs without errors. Submit your hello.py file to Moodle.