Python notes for year 11 Computer Science
Python notes for year 11 Computer Science
following:
Python Programming
For example:
Note: single line comments start with # Note: Comments start with „, an
apostrophe or REM.
For the purpose of IGCSE, we adopt single
line comments. However, there are other
comment styles too.
There are multiple uses of writing comments in Python. Some significant uses
include:
Increasing readability
Explaining the code to others
Understanding the code easily after a long-term
Including resources
Re-using the existing code
Students are advised to read up the following and their use:
Expression Symbol
Not equal to != eg. If x!=3:
assignment = eg. myNumber=20
equality == eg, if x== “3”:
Others include
1. if statement
a = 33
b = 200
if b > a:
print("b is greater than a")
2. if …else statement
a = 33
b = 200
if b > a:
print("b is greater than a")
else:
print(“a is greater”)
3. if…then…elif statement
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Loops in python:
1. while loop
Eg. 1
i=1
while i < 6:
print(i)
i += 1
e.g. 2 Result:
2. for loop
Arrays
Data types and use
Using loops with conditional statements
Problem solving exercises