PAPER 1(100% CORRECT.)
What is an algorithm - ANSWERSAn algorithm is a set of rules or sequence of steps
that specify how to solve a problem
What is an integer give an example - ANSWERSa whole number that can be negative
or positive e.g -1 or 34
What is a real/float - ANSWERSa decimal number that is negative or positiive
What is boolean - ANSWERStrue or false
What is a character - ANSWERSA letter or a number
What is a string - ANSWERSanything enclosed by quotation marks also known as a
series of characters
What does the round function do - ANSWERSrounds the number to the given value e.g
- 6.56664 rounded to 2 decimal places is 6.6
What does the trunc function do - ANSWERSthe trunc function rounds a real number to
the nearest whole number it basically cuts the decimal part off. 4.55 truncated is 4
What does exponentiation do - ANSWERSRaises to the power e.g 2^3 = 8
what does integer division do - ANSWERSgives you the remainder. div finds the whole
number whilst mod finds the remainder
What does the len function do - ANSWERSreturns the length of an object or number of
characters in a string
What does the string.substring function do - ANSWERSit returns the portion of the
string inclusive to the index e.g word = ' hello' word.substring(index1,index2) = he
what does string.find do - ANSWERSif the variable is a string it returns the index of the
first string and if not it returns a -1
what does ord do - ANSWERSreturns the integer value of a character a-97
what does chr do - ANSWERSreturns the integer represented by a character 97-a
What does concatenation do - ANSWERSit joins two strings together
,how do you convert a string to an integer - ANSWERSint('string')
how do you convert a integer to a string - ANSWERSstr(123)
how do you convert a string to a float - ANSWERSfloat('123.34')
how do you convert a float to a string - ANSWERSstr(123.343)
What is a variable - ANSWERSan identifier given to a memory location whos contents
may be changed during the course of a program they should always be given
meaningful names
What is a constant - ANSWERSwhen the value of the variable never changes and stays
fixed/
Whats the advantage of using a constant - ANSWERSThe advantage of using a
constant is that in a long complex program you reduce the risk of accidently changing a
variable or reuisng the same name you used for the constant. an example of this could
be wanting to keep pi = 3.14
What are the three basic programming constructs - ANSWERSsequence, selection,
iteration
What is a sequence - ANSWERStwo or more statements following one after the other
What is an assignment statement - ANSWERSA statement that sets a variable to a
specified value.
What is a selection statement used for - ANSWERSto select which statement will be
executed next depending on some conditions. This conditions are mased using
relational operators
What is a CASE statement - ANSWERSA way of writing complex selection without lots
of ELSE Ifs
What is AND, OR, NOT,. XOR - ANSWERSBoolean operators
What is XOR - ANSWERSit means that its either a or b but never both
what is an iteration statement - ANSWERSone that performs a loop in the program
What are the two types of iteration - ANSWERSindefinite and definite
What is indefinite iteration - ANSWERSthe number of repititions is not known before the
loop starts. this would be a while loop
, What is definite iteration - ANSWERSthe number of repititions is known before the loop
starts. like a for loop
What is a data structure - ANSWERSa collection of data types
What is an array - ANSWERSA finite, ordered set of elements of the same data type
what is a subroutine - ANSWERSA named block of code which performs a specific task
within a program
How is a subroutine called? - ANSWERSby writing its nae in a program statement
what is the difference between a function and a procedure - ANSWERSa function is
called like the input function, always assigning a return value to a variable. Whereas a
procedure doesnt allows have to return something like a print statement
what are the two mechanisms for passing a parameter - ANSWERSby value and by
reference
What is the difference of passing a parameter by value vs by reference -
ANSWERSWhen passing by value , changing the parameter inside the subroutine will
not have an effect on the outside value of the subroutine. Whereas when a parameter is
passed as a reference the address of the parameter not its value is passed so any
changes made in the subroutines will be reflected in the program
whats the difference between global variables and local variables - ANSWERSglobal
variables can be accessed anywhere in the program whereas local variable can only be
accessed within the subroutine it was defined in
Why are local varaibles useful - ANSWERSit ensures that each subroutine is completely
self contained and independent of any global variables
why is data hiding and encapsulation important - ANSWERSa subroutine written using
these princibles can be tested independently
What are the advantages of using a subroutine in a large program - ANSWERSa
subroutine is small enough to be understandble so its easy to debug and maintain. They
can be tested indipendently therefore shortening the time taken to get a large program
working.
why does data need to be stored in a file or a disk - ANSWERSif you want to store the
data permanently so that you can read or update it in the future
What does a file consist of - ANSWERSa number of records