0% found this document useful (0 votes)
2 views7 pages

9.2 Python Revision Guide

The Year 9 Revision Guide introduces Python programming, covering variable rules, data types, and the development environment. It explains the importance of pseudocode for planning algorithms and identifies common programming errors such as syntax, run-time, and logic errors. Additionally, it discusses the use of while loops and the impact of new technologies in programming.

Uploaded by

ahsunnafis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

9.2 Python Revision Guide

The Year 9 Revision Guide introduces Python programming, covering variable rules, data types, and the development environment. It explains the importance of pseudocode for planning algorithms and identifies common programming errors such as syntax, run-time, and logic errors. Additionally, it discusses the use of while loops and the impact of new technologies in programming.

Uploaded by

ahsunnafis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Year 9 Revision Guide

9.1 Introduction to Python


Lesson 1 – Introduction Rules for variables
• A variable name can contain only numbers, letters and underscores
• A variable name cannot start with a number
• You can’t use a Python “reserved word” as a variable name – for example
class is a reserved word so class = input() will result in a syntax error.

Python’s Development Environment

IDLE – Integrated Development Environment. There are two Modes:


– Interactive Mode let you see your results as you type them
– Script Mode lets you save your program and run it again later

Variables
• A variable is a location in memory in which you can temporarily store text
or numbers
• It is used like an empty box or the Memory function on a calculator
• You can choose a name for the box (the “variable name”) and change its
contents in your program
Lesson 2 – Numbers and arithmetic

Data types

• String holds alphanumeric data as text


• Integer holds whole numbers
• Float holds numbers with a decimal point
• Boolean holds either ‘True’ or ‘False’

Defining variable data types

• Python automatically assigns a data type to a variable


• You can override this to manually define or change the data type using:
– str() str(animal_name)
– int() int(goals_scored)
– float() float(share_price)
• This is called Casting
Lesson 3 – Selection
Lesson 4 – Writing algorithms Types of programming error

Writing pseudocode Syntax Errors - when a line of code cannot be understood – eg missing a “ or )
• Pseudocode is half code, half English [Link]

• It has no real syntax and would not run


Run-Time Errors – a run-time error is caused by a problem that the program cannot
• It is a structured sequence of instructions resolve whilst it is running. An example would be a division by zero, or being unable
to locate a file that the program is looking for.
• It is useful for planning algorithms
[Link]

Suggested language for pseudocode


• Use indentation in pseudocode Logic errors - a program with a logic error will run and appear to be working.
However a calculation may be wrong and cause a wrong result to be output.
• Use words such as: Program may crash.
[Link]
print, display,
input, output,
calculate, add,
set, reset,
if, then, else
Lesson 5 – While loops
Lesson 6 – Convergence and new technologies

You might also like