Mapa mental
2.2 Programming Basics
Contenido del mapa
2.2 Programming Basics
Data Types
- Integer
- int
- Whole Numbers
- Boolean
- bool
- Can only take two values such as TRUE or FALSE
- Character
- char
- Single letter, number or symbol
- String
- string
- Used to represent text, a collection of characters
- Casting
- Conversion between data types
- int("1)
- float(1)
- bool(1)
- str(True)
- Real(float)
- Decimal numbers
- real
- Integer
Basic Operators
- + is Addition
- - is Subtraction
- Multiplication is *
- Division is /
- Exponentiation is ^
- Quotient is DIV
- Remainder (Modulus) is MOD or %
- Comparison operators
- == is equal to
- <> or !+ is not equal to
- < is less than
- > is greater than
- <= is less than or equal to
- >= is greater than or equal to
- <= is less than or equal to
- > is greater than
- < is less than
- <> or !+ is not equal to
- == is equal to
Constants and Variables
- Constants are assigned to a data value at a designated time that cannot change.
- Variables can be changed, unlike constants
Strings
- Strings are written inside quotation marks
- x.upper will change all characters in string x to UPPER CASE
- x.lower changes all characters in string x to LOWERCASE
- x.length will return the number of characters in string x
- x[i] will extract the character in position i from string x
- x.subString(a,b) will extract a string starting at position a with length b from string x
- Strings are written inside quotation marks
Program Flow
- IF statements
- Checks if condition is true or false.
- Nested IF statements
- Allows you to check more conditions once you've established that the previous condition is true
- Made by putting one IF statement inside another
- IF-ELSEIF statements can also be used to check multiple conditions, however, nested IF statements can only check more conditions if the previous condition is false
- IF statements
SWITCH-CASE statements
- Used to check if a variable has specific values
- Used when you want a program to perfom different actions for different values of the same variable
- Can only check value of one variable
- Used to check if a variable has specific values
FOR Loops
- Will repeat the code inside them a fixed no. of times
- The no. of times that the code is repeated depends on initial value, end value and step count
DO UNTIL LOOPS
- Controlled by condition at the end of the loop
- Continue until condition is true
- Infinite loop is condition is never true
WHILE LOOPS
- Controlled by condition st start of loop
- Continues while condition is true
- Never runs if code is initially false
DO WHILE LOOPS
- Controlled by condition at end of loop
- Continues while condition is true
- Always runs code inside at least once
- Infinite loop when condition is always true
Booleean operators
- AND will only return true if two things are True
- OR will only return true if one of the things are true
- NOT will only return true if there is one thing that is a LIE
Arrays
- A data structure used to store a collection of data all under one name
- Useful for storing related data
FILE HANDLING
- To open a file, you must open it and assign it to a variable
- Program will start reading or writing from the beginning
- When finished reading/writing, close it use close() or the file can remain locked and prevent others from editing it
- Program will start reading or writing from the beginning
- Reading/Writing
- writeLine() will write lines of text to a file and overwrite already existing text
- readLine() will allow you read lines of text from a file
- endOfFile() will allow you to signify when a program should stop reading a file.
- To open a file, you must open it and assign it to a variable
Storing data
- Record will store a collection of data values
- Each item is called a FIELD
- Each field gets a name and a data type
- Fixed in length, so extra fields can't be added when created
- Record will store a collection of data values
Searching data
- SELECT is followed by the names of the fields you want to find
- FROM is followed by the name of the table that you want to search
- WHERE is used to specify condition that a record must satisfy before being returned
- ORDER BY sorts records into ascending or descending order
- WHERE is used to specify condition that a record must satisfy before being returned
- FROM is followed by the name of the table that you want to search
- SELECT is followed by the names of the fields you want to find
SUB PROGRAMS
- Procedures are sets of instructions stored under one name
- Functions always return a value
- Parameters are sued to pass values into a sub program
- Arguments are the actual values that the parameters take when the sub program is being called
- SCOPE(tells you which parts of the program the variable can be used in)
- Local variables can only be used within the structure
- Scope only extends to sub program they are declared in
- Global variables can be used any time after declaration
- Local variables can only be used within the structure
- SCOPE(tells you which parts of the program the variable can be used in)
- Arguments are the actual values that the parameters take when the sub program is being called
- Procedures are sets of instructions stored under one name
Información
- Descripción
- GCSE Computing Mapa Mental sobre 2.2 Programming Basics, creado por Gabriel Gozo el 06/06/2019.
- Creado por
- Gabriel Gozo
- Visitas
- 1
- Valoración