Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
258 views

GCSE Computer Science SQL and Databases Revision Notes

This document contains information about Python including: 1) Strings must be printed with quotation marks, but if statements do not require them. Indentation with tabs is required after colons. 2) For loops iterate through a range of values, incrementing the variable on each pass. While loops check a condition and run the block until it is false. 3) Arrays are variables that contain other variables. A for loop can print array values vertically.

Uploaded by

Tim Millard
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)
258 views

GCSE Computer Science SQL and Databases Revision Notes

This document contains information about Python including: 1) Strings must be printed with quotation marks, but if statements do not require them. Indentation with tabs is required after colons. 2) For loops iterate through a range of values, incrementing the variable on each pass. While loops check a condition and run the block until it is false. 3) Arrays are variables that contain other variables. A for loop can print array values vertically.

Uploaded by

Tim Millard
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
You are on page 1/ 2

SECTION 1 – THINGS TO REMEMBER IN PYTHON

Strings are text in python. When


printing them you must put them in
brackets and surround them with
quotation marks. The same does not
apply for if statements.

Put a colon after an if statement.


After a colon,
put a full tab This is a comparison operator. It could
space as an also be: !=, <>, >, <.
indent. This
command This is a variable, it has been defined.
All variables must be defined, we use
executes when
the statement is an = sign for this.
true.

SECTION 2 – LOOPS IN PYTHON

In this for loop, the variable “i” is assigned to the first value in the range, this is then printed in the
second line. Next, the “i” variable picks up the second value which is then printed. This process is
repeated until the end of the range. This would altogether produce:

In this loop, “var_x” starts as zero, which is less than 100. So the next line is executed and the print
statement is called. The next line adds 1 to “var_x”. As this is the end of the loop, x is once again
checked to see if it is less than 100. This cycle is then continued until var_x = 99. This would
altogether produce:

This repeats even more


until “var_x” = 99
3

In this loop variable values, text and a calculation are concentrated (joined) in one line. The text
(strings are contained between the quotes in green. The commas are used to concentrate the
different elements of code. In the print statement the first “var_x” gives its value, and the “y*x”
does the calculation. This would altogether produce:

Notice that its like a times


table

SECTION 3 – ARRAYS IN PYTHON

This is an array variable. Array variables are variables that contain other variable. If I printed this
array, it would look like this:

But if I add a for loop like this:

The end result would print vertically like this:

You might also like