Hello World
Last updated
Last updated
Download version 3 of Python for your operating system from www.python.org
Install Python then search for an open the Idle Python application.
The screen that you see in Idle lets you run one line of Python code at a time.
It is a tradition amongst programmers that the first program that you write in any language is the Hello World program.
In Idle type:
and press return.
Congratulations. You've written your first program!
Obviously you'll want to write programs that are bigger than one line. To do this we need to create a Python file.
Python files always end in .py
In Idle, go to File > New and save the file to your OneDrive folder. Call it YourName.py
The program that we're going to write will ask you for your name before then saying hello.
In your Python file, write out the following code:
Lets take a closer look at this program line by line:
A # hash at the start of a line means that it is a comment and not an instruction for the computer
Input means that a user should input some text. This is saved into a variable called name. The \n in the text tells python to move down a line (like pressing return in word)
Terms separated by a comma , in print are joined together when they are printed.
To run your program, click Run > Run Modules or press Fn-5
Play: Can you modify your program to write your name 5 times? How about asking for someone else's name.
Create a file that asks the user for a noun, adjective and verb ending in ed before printing it with the command