Python is one of the fastest growing and one of the most used programming languages in the world. It is used in most schools, universities and many large companies across the globe. You are going to learn the basics of the Python language.
It is a text based language so you’ll have to learn the specific keywords, exact grammar and correct punctuations to set out instructions - they have to be perfect to run! Coding is frustrating (unless you are like Mr Balfour and find it very therapeutic 🤪) so take your time and check carefully but keep persevering!
Getting started with Python
- Open your Z Drive on your computer
- Open your Computing Folder
- Create a new Folder called Python
The program we will use for this is called Thonny.
To access this open the folder on the server found at:
- Subjects
- Computing
- Pupils
- Apps
Now copy this folder to the Desktop on your computer.
When the files have copied fully, open the folder on your Desktop and double-click the thonny.exe icon to run Thonny.
Hello world!
In this lesson, you are going to be producing something on the screen of your computer.
Python uses the keyword print
to send something to
the computer's screen.
Type in the code below exactly to lines 1, 2 and 3.
print("Hello world!") print("Hello Haddington!") print("Hello Knox Academy!")
To run the code, click on the 'play' icon.
-
When you have run the code, upload a screenshot of it running below:
-
What does this program do?
About Me
Make a new Python program and save it as "About Me" in your Python Folder and write a program to display 3 sentences.
- One that says your name
- another that says what your favourite TV show is
- and a third stating what your favourite animal is.
Test run the program, fix mistakes and edit if need be.
Take 2 screenshots:
- One of the code
- One of the working test run
-
Screenshot of the code
Screenshot of the output
About Anyone
The About Me program worked for you. We need to be able to write flexible programs that can work for many users in many situations. For this, we can use variables.
name = "John Franklin" tv_show = "The Terror" animal = "Polar Bear" print("My name is", name, ".") print(tv_show, "is my favourite TV show.") print("My favourite animal is", animal, ".")
Change the code so it works for your information then screenshot the changed program and the working output test run below.
-
Screenshot of the code
Screenshot of the output
- What is a variable?
- Describe how they are used in a program.
- List some of the advantages of variables.