The first program in the 1978 book “The C Programming Language” was to print “hello world!” on the screen. Since then it is used as the first program to introduce the basics of a programming language.
Select the button below to open the Python program in a new window. Run the program and read the lines of code to see if you can understand how it works. It will be helpful to arrange your display so that you can have this browser window on one side of the screen and the code on the other.
Watch this video to learn about the new concepts shown in the program:
Questions to think about with this program to check your understanding:
Identify a string in the program.
The words “Hello World” is a string.
State what strings must always be enclosed in.
Strings must be enclosed in quotation marks (also known as quotes, quote marks, speech marks, inverted commas, or talking marks). You can use single or double quotes. These are known as “qualifiers”.
Change the program below so that it:
Hello World
This is my first program.
Use these resources to learn about new commands for this level and to help you meet the success criteria.
#
is used to start a comment. Comments are used to explain the purpose of parts of the program.
def subprogram_name():
Defines a new subprogram. Subprograms are also called subroutines. They are used to deconstruct a program into smaller parts to make it easier to read and solve. Code must be indented inside the subprogram with a tab, two or four spaces. You cannot use spaces in the name of a subprogram, so use underscores to separate words instead. Don’t forget the colon at the end of this command.
print(x)
Outputs x to the screen. Each print statement puts the output on a new line. You can prevent a new line by concatenating `end = “”` to the output. E.g.
print(“Hello”, end = “”)
print(“World”)
print()
Outputs a blank line or ends the line if a new line was prevented.
Run the unit tests below to check that your program has met the success criteria.
Hello World
This is my first program.