Introduction to Python
One key message this week is to look at the syllabus. This outlines what you need to learn for the GCSE. the syllabus is available from OCR's website, here. The relavent information is located on pages 6-11 for your exam component.
This week we have had a look at the python language, and how we can start using it.
Python can be downloaded to your computer at home for free from this site. Be sure to check that you are using version 3, and that you check the system that you are working from.
The documentation for python is located at docs.python.org. This documentation is fantastic! However learning programming involves a steep learning curve which we shall ascend carefully. The language in the documentation is designed for programmers, it is a difficult attack for you now, but that is no reason to "dumb it down". With a bit of perseverance, and a few questions you will get this in no time.
We wrote our first program in lessons this week. You can find the program I wrote here.
Github is great for sharing programs, and for editing other peoples code. we will not use a lot of its functionality during the GCSE course, but if you continue programming in any way it will become invaluable.
Key notes
Functions
- A function is declared using the def keyword. (short for define)
- A function definition is an executable statement.
- The function definition does not execute the function body;
- this gets executed only when the function is called.
Variables
- A variable is a place in memory that can store a piece of data.
- A variable is set up when a value is assigned to it using a single equals sign.
- A variable can have any name which is not already defined as a built in keyword,or function.
- A piece of data can be;
- A string
- word = “hello class”
- strings are text. ie a collection of letters, numbers, and punctuation.
- A number (integer or float)
- number = 4
- number = 4.0
- Numbers can have operations performed on them. as shown in the documenation.
- A list
- Things = [1,2,3,4,5,]
- lists have operations on them, for examples see the documentation.
Key words
This week we have used a number of other key words in lessons.
- Integer
- A whole number (positive or negative)
- Float
- A number with a decimal point (positive or negative)
- String
- Text.
- Floor
- Rounded down number.
- The opposite to the floor of a float is its ceiling (ceil).
- Product
- Result when two numbers are multiplied.
- Quotient
- Result when two numbers are divided.