ICS3U Python Programming Environments

ICS3U Learning Goals

In this ICS3U lesson you will be learning how to:

  • Download and install Python to your computer
  • Use an Integrated Development Environment to write a python program

Python Programming Language

ICS3U ICS4U Python Image

You are going to be writing computer programs using the Python Programming Language 

  • Any Python v3.XX is appropriate.
  • Definitely do NOT use v2.XX as there are significant differences

Python is an Interpreted language and thus needs the python interpreter to run the code.  We can run that interpreter on our machines or through a server on the web.

It is VERY STRONGLY recommended that you have a PC/MAC to complete this course, as there is software that needs to be installed that is not available on Tablet Devices.

  • There are work arounds to this, but they are not very user friendly.
  • All of the lessons should be able to be viewed on any device, however completing the practice questions and assignments is best done with a PC/Mac

Learning Programming Concepts in ICS3U

ICS3U Python Trinket

I believe that passively acquiring information is NOT the best way to learn how to write computer programs.  During portions of each lesson you will be required to complete short Interactive Learning Activities.  In these activities you will be learning about small concepts and how certain pieces of code work.   You will do this without having to leave the browser window and go and use different software.  To accomplish this I have embedded what is known as a Python Trinket into the lessons.  

For example, if you click on the toggle button you will be able to open a Python Editor and type and run the code snippets that are given to you in the activities.

Interactive Learning Activity

Open the Toggle name “Python Editor” and type the following code into the Python Editor and Run the code to see what happens

				
					name = input("Enter your name: ")
print("Hi",name)

				
			

You can switch back and forth between running the program (Arrow) and using the editor (Pencil)

ICS3U Trinket Editor Run

Trinkets are good to run small pieces of code for teaching and learning purposes, but most programmers don’t use a web based python kernel to write their programs.

Integrated Development Environments

The most common way to write programs in python is to use an Integrated Development Environment (IDE). An IDE contains

  • An editor, that lets you write the code
  • A python interpreter, that takes your code and translates into machine code. The running program is displayed in the “Python Console”
  • Debugger, allows you to test and trace through your code to find errors
IDE’s get installed onto your computer just the same as any other software package.  There MANY options that you could use for Python Programming.  It really makes absolutely NO difference to me what you choose to use.  Below are some options that I think are appropriate. 
 
You will see that inside the lessons there will be Practice Questions that I recommend you code with an IDE instead of inside the embedded web trinket.

IDLE

This is the most straightforward and lightweight way to create and run python programs on your computer.  It comes built in when you download python from python.org.  (If you are an HWDB student on a school board machine running windows 10, you can install python and IDLE from the “Software Center” in the Start Menu. )

Conda Distributions and Spyder

ICS3U Spyder Download

An alternative to the base Python installation, you can use a Conda Python Distribution.  This has several advantages (most not relevant to this course) and is compatible with the SPYDER IDE.  This is my primary python distribution and IDE that I always use.  I used Spyder to make most of the videos in this course.  

The Conda distribution is very popular in Industry and has a lot of utilities that are useful if you are interested in Data Science or Artificial Intelligence Programming. 

There are two main distributions you could consider:

  • Anaconda Python Installation – Its a large software package, that takes up a lot of resources, but comes complete with pretty much everything out of the box
    • You only need the Free Individual Edition.
    • Install Files for all Operating Systems are at the bottom of the page 
  • Miniconda Installation – Barebones python installation and you just install the packages you need when you need it.
    • You can pick your operating system from the list
At home you won’t have a problem getting this installed on your computer, but It will likely be very difficult to get this installed and working correctly on a School Board Managed Machine without a Teacher’s assistance (and even then its still a pain) if they don’t know what they are doing!!!

UPDATE: SEPTEMBER 2022

I’ve been having students encounter significant issues with getting Spyder to work with the anaconda distribution.  The version of Spyder available on anaconda is Spyder v 5.1.5 There is a bug that will not allow you to use simple input statements (which are used in every question in this course) and there is no way to update Spyder in the anaconda environment to the newer version properly at the moment 

So at this point, I cannot recommend the anaconda package be installed

UPDATE: SEPTEMBER 2023 – Issue may have been fixed, currently looking into it

However, the miniconda version does have Spyder 5.2.2 which seems to fix the above issue. 

Once you download the installer and install the distribution:

  • On Windows if you just search (bottom left corner) for “anaconda prompt”, it will open up a terminal window then you can type the following to install Spyder:
      • conda install spyder
  • If the install fails, you might need to run as an administrator and try again
  • Once it finishes successfully you can just search Spyder in the Search Bar and Spyder will open
  • I don’t have a MacOS so I’m not 100% sure on the process to get anaconda prompt to open, but once you find it you can type the same command

Below is a video about Spyder and the Anaconda Distribution.  (I don’t have a video for the miniconda install, but Spyder is the same in both anyways)

Spyder has a newer version 5.3 and can be installed as a standalone app without conda from https://www.spyder-ide.org/, but that will create other issues when trying to install packages that we use in grade 12, so I don’t really recommend that either.

Replit

ICS3U Replit Download

If you are ever stuck and not able to install an IDE on your device, then Replit “should” work on any device that has web access.  I would only recommend this as a last resort for ICS3U. It has the advantage of making all your code available anywhere you have a web connection. There is no install. In my experience it isn’t as fast or user friendly and requires you to create an account to sign up. Please be mindful of what personal information you give to other websites. If you are thinking of going this route, you must let me know so I can inform your parents about any privacy concerns that could exist.

Pycharm

Pycharm is another very popular IDE that is used to create larger python projects.  I just started using it for some personal projects, so there isn’t going to be a demo video right now, but you are free to download and see if you can figure out how it works.  

  • You would want to use the Free “Community” version that is available to download. 
  • There is an educational version as well free to students, but you would have to sign up.  (Always beware of giving personal information away to companies)
Pycharm has a nicer project management system than Spyder in my opinion and you can have a different environment with different packages for each project.  Which is nice, but not necessary in this course.  It doesn’t seem to play nice with networked drives and cloud storage however.
 
If you want to try it, go for it and you can ask me questions if you want.
 

 

Python Interpreters

Keep in mind if you are trying different IDE’s and installing different versions of Python, they will likely each install their own Python Interpreter on your machine.  

That’s not really an issue, but if you are installing external packages, they might install to a different interpreter then expected.  Shouldn’t be an issue with this course, but something to keep in mind if you notice it.

Python Files

Whenever you save your python files in ICS3U from an IDE they will have the .py extension.  That is what you will hand in when I’m grading your work.  There is nothing special about these files, it is just your program code as you have written it in the editor.  

They will not however open in your IDE like regular Word or pdf files by “double clicking” them in your file manager.  If you do that, then your OS will likely try to actually just run the program using the python interpreter.  If you want to open and edit them, then that must be done within the IDE

Note to HWDSB Students…. Trying to send .py files in outlook email in our system likely won’t work as our security system treats them as a dangerous file.  

ICS3U Activity

Task #1 – Install the base version of python and the IDLE IDE

  • https://www.python.org/downloads/
  • Open IDLE and then
    • Create a program called “demoIDLE.py” and enter the code below.  
    • Get the program to run on your device
  • Make sure you are able to find that file in your file system so when you do assignments you can hand in your work.
				
					name = input("Enter your name: ")
print("Hi",name)

				
			

Task #2- OPTIONAL – Try out a different IDE

Option – Install the Conda version of python and the Spyder IDE

  • https://docs.conda.io/en/latest/miniconda.html
  • Open miniconda terminal window and type
    • conda install spyder
  • Open Spyder and then
    • Create a program called “demoSpyder.py” and enter the code above  
    • Get the program to run on your device
  • Make sure you are able to find that file in your file system so when you do assignments you can hand in your work.
Option – Try downloading and installing Pycharm

Let your teacher know in the discussion forum the results of your activities. Were you successful?  
Return to ICS3U1 Main Page