Please enable JavaScript.
Coggle requires JavaScript to display documents.
Computer science Paper 1 revision - Coggle Diagram
Computer science Paper 1 revision
Programming
Data types
All data is stored in one way or another. A data type is defined as by the values it can take or the operations that can be preformed on it.
Some times . some solutions might require the storing f one data using various data types. in this case , programmers use the best suited data type to solving the particular problem.
Data types
Integers
A whole number , positive or negative , including zero.
Real / floats
A positive or negative value which can have a fractional part.
Character
A collection of characters/
Boolean
A value which is either true or false.
String
A single number ,letter or symbol/
Arrays
A data structure that can only store one type of data type on it or a finite indexed set of related elements which have the same data.
String-heading operations
As discussed earlier , a string is a collection of characters. Strings can have different functions applied to them.
String to integer
Converts a string to an integer
int(input())
String to float
Converts a string to a float
float(input())
Character to character code.
Returns the character represented by a given character code.
Concatenation
Joins two or more strings together to form a new , longer string.
Print("hello " + name + "how are you today " + age)
Length
Returns the numbers of characters in that specific string.
Len(name)
Programming concepts.
Important
Constant declaration
The same as variable declaration but creates a constant. A constant is a value that does not change whilst the program is running.
Assignment
Giving a constant or a variable a a value
Meaningful variable names
When declaring constants , variables and subroutines , it is important to give them sensible names. This is because it makes it easier for others to understand what the purpose of the named object is.
Variable decliration
Creating a variable for the first time , giving it a name or sometimes a data structure which allocates memory space to the variable.
Selection
Comparing values and choosing an action based on those values.
Iteration
Repeating an instruction , this could be definite or indefinite
Types
Indefinite
In contrast to definite iteration , indefinite iteration is used when numbers of iterations required are not known until the loop starts.
Definite
Definite iteration is a type of iteration in which numbers of repetitions required are known before the loop starts.
Nested structure.
Selection structures and integrations can be nested. this means that they can be placed within another and can easily be identified by different levels of indentations in code.
Why is indentation needed ?
Whenever a new section of iteration structure begins , the code moves to a higher level of indentation making it easier for humans to understand.
Subroutine
A named block of code containing sets of instructions designed to preform frequently used operations.
parameters of subroutines.
Parameters are used to pass data within a subroutine in a program. This is usually specified using bracets after the subroutine call.
Example Code.
Length ← USERINPUT
Width ← USERINPUT
OUTPUT CalculateArea(Length, Width)
SUBROUTINE CalcualteArea(x, y)
RETURN x * y
ENDSUBROUTINE
Arguments
Arguments are the actual values passed through the parameters.
Functions and procedures.
Both functions and procedures are subroutines and are called by writing their names. Whilst both functions and procedures can can return a value , functions are required to return a value whist procedures are not.
Local and global variables.
A local variable is a variable that can be accessed from the subroutine which it is decaled in.
A global variable is a variable that can be accessed form any part of a program.
When a local variables value is changed , the global variables value remains the same.
Arithmetic operators
Addition
When two values are added together resulting in the sum of those two Values.
Multiplication
The product of two numbers returned when multiplied.
Subtraction
When one value is subtracted from another . which results in the difference of those two numbers.
Float division
When one value is divided by another , both a quotient and a remainder is retuned.
Integer division
Integer division returns the whole part of a number.
Modulo
Returns the remainder of integer division.
Exponential
Raising one value to a power of another.
Truncation
Removing the decimal part of a number.
Rounding
Limiting the degree of accuracy of a number.
You can make use of relational operators whenever you need to compare the two values. they are used in interactive and selection structure.
Less than
44 < 90
Greater than
45 > 22
Not equal to
15<>43
43 != 433
Less than or equal to.
5 >= 2
5 >= 5
Equal to
14 = 14
Greater than or equal to.
20 >= 122
Structured approach
The structured approach uses uses programming design to keep the code easy to uhndersnd and manage.
Decomposition is the breaking down of tasks into smaller sub tasks.
Abstraction is the removing of unnecessary details.