Welcome to the start of Python programming. In this course we will look at the 5 main building blocks of all computer programming:
input - putting things into the computer mainly typing things in on the keyboard
output - getting things out of the computer mainly putting things on the screen
sequential instructions - stuff that is done in order
iterative structures - how the program can repeat the same thing without having to write it all out again and again and again...
conditional structures - how the program can make decisions about what to do
Using these elements we can build more and more complicated programs.
We will be mainly using the Python programming language and environment on this course but the ideas and skills covered form the basis of all programming languages.
You can work on Python in a couple of ways.
IDLE
This is loaded on the computers in T3 and is free to download and install on your home computer/laptop too. Search for python download or go to https://www.python.org/downloads/ and download the latest version of Python when you get home. Having a copy of Python running on your own computer means that you have access to your programs without needing the internet and you can customise/add other things later as you need them. We'll be using this in class to learn Python, but...
Online editors
If you are using a Chromebook you can play with Python online ouside of class using an onlne editor. Go to https://www.online-python.com/ and you'll see the left hand side of the screen is where you write your code and when you run it you'll see the results in the righthand half of the screen.
Search for IDLE in the program search box in the taskbar. That's the box in the middle bottom of the screen, not in Google. This will open the Python Shell, you can tell by the >>> on the left hand side. If you type commands in here they run as soon as you press Enter. It is a great place to try out small pieces of code but to make bigger programs you ned to open a new file. Click on the File menu and select New File, this will make a new, empty window where you can type your programs.
There is a video at the bottom of this page that shows you how to get started in IDLE.
Before you can run a program it needs to be saved. Keep your files organised with sensible file names. The convention we will use is firstname.lastname description so if I were to save a program about snakes I would call it niall.pearce snakes, if the program is about painting a house I would call it niall.pearce painting.
replit automatically gives your programs weird random names, so make sure you rename them or you will be wondering what SupriousDolphin is about.
Most of the work you will submit in this course will be pasted onto the Google Docs that contain the instructions.
When you copy and paste your code from IDLE into the appropriate section of the doc I can see it and give you feedback on it, you don't need to turn it in. You may need to explain this to your parents if they get the weekly summaries and it says you have documents outstanding.
I will use the 'grade' to indicate how much of each week's work has been completed. The main part of your homework will be to get each doc to 100 before we start the next week's work.
It is important that YOU understand the ideas in each week's work as they will be used in future weeks. Copying your friend's code into your doc may seem like a good idea at the time, but when we build on that work in later lessons you won't know what's going on. If YOU don't understand how somehing works ASK. Ask me, ask your fiends, look on this website, search for it on the internet - it is your job to understand it.
Comments are very important in programming. You write your program and know how it works. You test it to make sure all is well. You do this ONCE and then you share your work with the world where MANY other people may try to use it. The comments you add to your work make it much easier for them to understand what each bit of your program does and why you chose to do it that way. This can save you hours when you are trying to figure out someone else's program so be kind and make sure you add comments into your code.
It is easy to add comments into a Python program, you just put a # at the start of your comment.
Start all your programs with a comment block that includes the name of the program, your name and the date you wrote it. eg
#Sharing Taxis Problem
#Niall Pearce
#14/2/23
***Note: The stuff in this website that is in these grey boxes is actual Python code. You can cut and paste it into IDLE and it should work.***
Then add comments through your work. These are ignored by the computer, they are just for us puny humans to read, so you can use everyday language, eg
#This bit sets up all the data the program needs
#This bit checks if the input is OK
#Calculates the total cost of the meal. It adds up the starters, mains and deserts separately
#then adds those totals up. This makes it easier to check the sub-totals and they may be needed
#later for a printout
The last comment is good because it explains why the program is designed in the way that it is. It doesn't just stating the obvious.
'Edit with IDLE' is on the 'show more options' menu