Hello World

Hello World

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.

Try


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:

Knowledge Organiser

Command summary

The new commands used in this program and others that may be useful. Select them below to learn more:

#

The hash symbol is used to start a comment. Comments are used to explain the purpose of parts of the program.

def subprogram(parameters):

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.

Investigate


Questions to think about with this program to check your understanding:

Item question

Identify a string in the program.

REVEAL ANSWER

The words "Hello World" is a string.

Structure question

State what strings must always be enclosed in.

REVEAL ANSWER

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".

Make


Success Criteria

Change the program below so that it:

  1. Outputs, "This is my first program" on the line below "Hello World".

Sample output from the program

Hello World

This is my first program.

Help

Use the flowcharts if you need more support in understanding the steps required to meet the criteria. Use the Parsons code sorting exercise only if you are really stuck.

Evaluate


Run your code to check that your program has met the success criteria and produces the required output.

Hello World

This is my first program.

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Craig'n'Dave logo

Craig 'n' Dave

Bett Awards 2024 Finalist