THE WESTMINSTER SCHOOL, DUBAI
Revision Notes
Computer Science
YEAR 08
INTRODUCTION TO PYTHON
COMPUTER PROGRAMMING:
• computer programming is a set of instructions given to computer to perform specific actions or
task.
A computer programmer is, a professional that creates instructions for a computer to execute by
writing and testing code that enables applications and software programs to operate successfully.
Python Programming;
❑ Python is one of the most popular and fastest growing programming languages in the world.
❑ Officially released in February 1991.
❑ Researchers, mathematicians, and data scientists in particular like Python because of its rich and
easy-to-understand syntax.
❑ Python has a simple, easy to learn syntax, which emphasizes readability.
❑ Applications written in Python can run on almost any computer.
IMPORTANCE OF LEARNING PYTHON:
✓ Python is extremely multipurpose, with multiple uses.
✓ Python is the fastest growing programming language.
✓ Python is in high demand for jobs.
✓ Python is easy to read, write, and learn.
✓ Python developers make great money.
print() FUNCTION:
An output function.
The print() function prints the specified message onto
the screen.
The message can be a string, or any other object, the
object will be converted into a string before written to the screen.
Information taken from user must be converted to desired data type, using int(), float(), string() ect
functions.
Always remember to use the (brackets) with print.
We also used “quotes” because we were printing text.
print is purple because IDLE recognises print as a Python command.
“Hello World” is green because it is a string of text (more on this later).
The printed output is usually blue.
Try below commands in online python Editor:
PYTHON VARIABLES:
A variable stores a value that can change.
A variable can store lots of different types of
information.
For example, the value could be a number,
text, or a list of items.
In programming, a number is called an integer or int for short. Text is called a string or str for
short.
A variable has two parts – name and value.
Assignment Operator is used to assign a value to the variable.
FirstName= “Anna” ------- [data type: String]
Age=13---------------[data type: Integer]
Height=151.5 ----------[data type: float]
RULES TO CREATE/DECLARE A VARIABLE IN PYTHON:
A Python variable must:
✓ be meaningful
✓ be one word
✓ have no spaces
✓ use no symbols
✓ Do not start a variable with a number.
✓ not be a reserved Python word
Practice below example in Online Python Editor:
EXAMPLE 01:
EXAMPLE 02:
EXAMPLE 03:
Definition and Usage
The append() method appends an element to the end of the list.
Syntax
[Link](elment)
*elmnt Required. An element of any type (string, number, object etc.)
Example:
Online Platform to practice Python code:
[Link]