Level 4: First Text Code
Python for beginners · KS3 Year 7
Works in the UK and the US. This version uses UK words and school years (KS3, Year 7). The US version uses US grades. · US version of this page
Your first steps in a real text programming language. Six short lessons, about 15 minutes each, that build up to programs which read input, do the maths and make decisions. Python runs right here in your browser, so there's nothing to install.
Before you start
- Run is free: press it as often as you like to see what your code does.
- Check marks your answer against tests. Some tests are hidden, so make your program work for any input, not just the example.
- When a task reads input, Classfern types the answers in for you when it checks your program. You can add a message too, like
input("Your name? "). - Stuck? Mr Babbage gives a hint about the part that went wrong.
Marked by Classfern in the browser – a practice check, not an exam. Your code is saved in this browser only. It runs in a locked box that can't reach the internet, and we never see it. Please don't put your real name, address or school in your code; a made-up name like "Sam" works just as well.
Lesson 1: Joining text and numbers
By the end you can:
- Join pieces of text with +
- Turn a number into text with str() before joining it
- Use an f-string to put variables into a sentence
Mr Babbage: Welcome to text code! Today we join words and numbers. Python's + only joins text to text, so a number needs str() first. Predict what will be printed before you press Run.
Lesson 1 opens here. It needs JavaScript switched on.
Lesson 2: Changing and swapping variables
By the end you can:
- Change a variable's value, with = and with +=
- Explain why a variable holds only one value at a time
- Swap two variables safely
Mr Babbage: A variable is a labelled box that holds one value at a time. Put a new value in and the old one is gone. Trace each line with your finger, and remember: swapping needs a spare box.
Lesson 2 opens here. It needs JavaScript switched on.
Lesson 3: Data types and casting
By the end you can:
- Tell int, float, str and bool apart
- Explain why input() always gives text
- Convert values with int(), float() and str()
Mr Babbage: Every value has a type: int for whole numbers, float for decimals, str for text and bool for True or False. input() always gives text, so turn it into a number before you do maths with it.
Lesson 3 opens here. It needs JavaScript switched on.
Lesson 4: Arithmetic operators
By the end you can:
- Use // for whole-number division and % for the remainder
- Use ** for powers
- Predict results using the order of operations (BIDMAS)
Mr Babbage: My engine loved sums! Today: // shares out whole amounts, % finds what's left over and ** makes powers. Python follows BIDMAS, just like your maths lessons.
Lesson 4 opens here. It needs JavaScript switched on.
Lesson 5: Input, process, output
By the end you can:
- Read numbers typed by the user
- Turn a formula into a line of Python
- Print a clear result
Mr Babbage: Nearly every program does three things: input (read), process (calculate) and output (print). Today you'll build small calculators. Read the formula carefully and copy it into Python exactly.
Lesson 5 opens here. It needs JavaScript switched on.
Lesson 6: if / elif / else
By the end you can:
- Choose between several cases with if, elif and else
- Put the conditions in the right order
- Test the boundary values
Mr Babbage: Now your programs make decisions. Python checks if, then each elif, then else, from the top, and runs only the first one that's True. So the order matters. Test the edges, like exactly 15 or 16.
Lesson 6 opens here. It needs JavaScript switched on.
Level check
Finished all six? The level check mixes questions from every lesson. Pass with 70% or more to move up to Level 5 when it opens.
The level check opens here. It needs JavaScript switched on.
For teachers and parents
Use one lesson as a starter, a homework or a cover lesson. Pupils need no account. Progress is kept in their own browser and shown by level and skill. Pupils who have only used blocks before are welcome: Lesson 1 starts from print().
Curriculum links
| Lesson | National Curriculum in England (KS3 computing) |
|---|---|
| 1. Joining text and numbers | Use a textual programming language to solve problems |
| 2. Changing and swapping variables | Use a textual programming language to solve problems |
| 3. Data types and casting | Use a textual programming language to solve problems |
| 4. Arithmetic operators | Use a textual programming language to solve problems |
| 5. Input, process, output | Use a textual programming language to solve problems; model real-world problems |
| 6. if / elif / else | Use a textual programming language to solve problems; model real-world problems |
Contains public sector information licensed under the Open Government Licence v3.0.
Python is a registered trade mark of the Python Software Foundation. Classfern is independent and is not affiliated with or endorsed by it. AP® is a trade mark registered by the College Board, which is not affiliated with, and does not endorse, Classfern.
Back to the Programming Department · All Classfern departments