The name of this assignment refers to a programming tradition - that your first program in any new language will display the words Hello World on the screen. You are currently learning Python, but the actual language doesn't matter as much as the ideas that make up your program. Once you understand how to program, it is fairly easy to swap between languages.
We are going to start by using IDLE to create a console application. IDLE comes with Python, which is a relatively small, free download...
The Python programming environment is called IDLE and can be downloaded from the Python download page.
I recommend that you install Python 3, so that we are all using the same version. Select the version that is suited to the type of computer you are using. Most students are using Windows. If you are using 32-bit Windows, or are not sure what type of Windows you are using, download and install the Windows x86 MSI installer. Users of 64-bit Windows can download and install the Windows x86-64 MSI Installer.
The IDLE user interface looks like this:
It's pretty straightforward to use. You can use it in immediate mode and type in Python commands to see what they can do, or you can select New File from the File menu to create a whole program in the editor. When you create a new file, don't forget to add the extension .py to the filename to indicate that the file contains a Python program.
Once you are usign the editor, you can type in your commands and comments - they will be colour-coded to help you to spot errors. You can run your program by pressing F5 or selecting Run Module from the Run menu. If you have not saved your program, you will be prompted to do that first.
We looked at both Python 2 and Python 3 commands in the lesson, but in the assignments we'll just look at Python 3 to keep things simple:
print() - text needs to be put in speech marks, e.g. print("Hello"), numbers don't, e.g. print(10) or print(A) (where A is a variable). You can also perform calculations and concatenations (joining text) using the + symbol, e.g. print(4+2) or print("Hello"+"World"). Note that in Python 2 the brackets aren't necessary, but it's a good habit to get into, ready for Python 3.
input() - asks the user to enter a number; the question goes inside the brackets, e.g. age = input("What is your age (in years)?"). Note that you need the name of a variable to store the answer. We will look at variables in a future lesson.
# - used to indicate a comment; these are lines in your program that don't do anything. They are like labels and are usually use to remind you (or someone else looking at your program) what it does. Any line that begins with a hash is treated as a comment and will appear in red, e.g. # My First Program.
NB. You will only need the print() command and comments for this assignment, but you can add input to the program if you would like to extend the task.
If you are unable to install Python then you can use Repl.it to run your programs on-line.
Being by downloading my sample program - HelloWorld.py. Click the right-mouse button on the link and save it into your My Documents (or wherever you keep your the Ill Health Team work). If you just double-click the file, it will run (possibly so quickly that you won't see anything), so click the right-mouse button on it and choose Edit with IDLE. If you're using Repl.it, then copy the program below and paste it into the editor:
print("Today is Monday.")
All I'm asking for this first assignment is for you to edit the program so that it prints information relevant to you. You will also learn how to open, save and run your programs. If you want to experiment and add extra features, then feel free!
Your program should:
display your name instead of Joe Bloggs. Make sure that your name includes spaces!
show the current day
The commands display Hello Joe Bloggs over three lines when you run the program - can you see why that happens? Is that what you'd want to see when you run the program?