Python 1

?

- coding is the construction of software
- involves writing an algorithm in programming language
- when the code is run the computer follows it step by step
- to define a variable, put "variable name = definition"
- to print something, "print variable"
- to print text and then a variable name, put print "...", variable name 

- the simplest python is a sequence of instructions, written one per line, and executed one by one from top to bottom 
result = 3 + 7 is an assignment
- the computer evaluates the expression to the right of the assignment (=) and stores the result in the variable on the left of the assignment, called result 
- the print command prints something to the screen
- the common separates two things to be printed
- text is written between double quotes, which are not printed themselves
- a sequence of characters surrounded by double quotes is called a string 

TypeError - the code is mixing different types of data

- python mathematical operators: plus(+), minus(-), multiplied by (), divided by (/) or to the power of (**)
- the # symbol is used for comments 
- blank lines and extra space are ignored 

- selection code if condition: block else:block chooses which block to execute
- the computer checks the condition after the if statement
- if the condition is true, the computer executed the block of code belonging to the if part
- if the condition is false, the computer executes the else block instead

- there are two combination operators 'and' and 'or' 
- combine selections using the 'and' operator if you require both selection conditions to be satisfied in order to execute the block 
- combine selections using the or operator if you require either selection to be satisifed in order to execute the block (either or both)
- the check whether a variable is greater than or equal to a particular value, use >=
> greater than
< less than
>= greater than or equal to
<= less than or equal to
== equal to
!= not equal to

- programs must be sustainablw: they should be written in such a way that they can be used effectively by many people, and be adapted and modified in the future 
- the first step when writing a program is to come up with an algorithm
- you should also consider validation and verification, clarity of the code and commenting and documentation 
- coding standards must be agreed, programs must be portable, and a test suite must be provided (a number of input sets and outputs for comparison)

Comments

No comments have yet been made