You are on page 1of 6

Harvey James

Textbook A-Level Computer Science Chapters 1-3


Chapter 1 questions:
1. Meaningful variable names, that indicate the purpose of the data, are used to help
programmers to trace bugs and allows other programmers to follow the code more easily.
2. A constant is an item of data whose value does not change e.g. π (pi): 3.1415…
A Variable is an item of data whose value could change while the program is being run, e.g.
the number of cars on the road.
3. So that the computer can quickly identify variables it does not recognise.
4. A variable is a container for data, a value is the data stored in the variable.
E.g. x=5, x is the variable, 5 is the value
5. a) Rate of VAT=0.2=Real/Float, because it contains decimals/is a real number
b) Todays Date=Date/Time
c) Total takings from a shop=Real/Float
d) Date of Birth=Date/Time
e) Which wrist a person wears a watch on=Right or Left=String

Chapter 1 Study/Research Tasks:


1. A two dimensional array is simply an array of one dimensional arrays. It uses 2 indexes.
You can imagine a 2D array as a matrix, a grid of numbers. For 2D arrays we must use nested
loops to reference every element in the matrix. This gives us a counter variable for every
column and every row in the matrix. We can use this type of data structure to encode
information about an image, such as a grayscale image, or to plot an x, y axis graph.
A three dimensional array is simply an array of two dimensional arrays, an array of arrays of
arrays. It uses 3 indexes. It can be used to represent the x, y and z coordinates of physical
space. A 3d array could be used to represent a 3D object, such as a cube by holding data
about its vertexes.
2. Visual basic has the following built in data types:
Boolean, Byte, Char, Date, Decimal, Double, Single, Integer, Long, short, Object, String.
3. Data types used to store sound and video data:
Lossy audio files: MP3, AAC, Opus, Vorbis, Musepack, ATRAC, WMA Lossy. Lossy audio files
lose quality when compressed
Lossless audio files: WAV, FLAC, WavPack, TTA, ATRAC, ALAC, MPEG-4 SLS, MPEG-4 ALS,
WMA Lossless. Lossless audio files retain quality when compressed.
Video file format: Flash Video, Vob, F4V, GIF, Ogg, MP4, AVI, MPEG-1, MPEG-2, WMV, MOV.
Video and Audio data types take up much higher amounts of space than others.
Harvey James

Chapter 2 questions:
1. Assignment: number1 = 29
Selection:
If number1 > 30 then
Output = “larger than 30”
End of
Iteration:
For counter = 1 to 50
Output = “Happy birthday”
Next
2. Website HTML code that tells the browser to repeatedly refresh the page until the user
clicks something or an algorithm that tells the computer to repeatedly change the order of
letters until all the different combinations have been formed.
3. A definite iteration is a process that repeats until a set number of times, while an
indefinite iteration is a process that repeats until a specific condition is met.
4. A nested statement is placing a set of instructions within another set of instructions
5. The sequence of programing statements is important because the instructions need to be
carried out in the correct order otherwise the results of the program will be inaccurate or
wrong. An example is outputting the answer before it is calculated.
6. Syntax are the rules of how words are used within a given language, which are important
because they give meaning to the language therefore making it useful and make sense. An
example is declaring a variable first before setting its value; as if you do it the other way
around you will get an error.
Harvey James

Chapter 2 Study/Research Tasks:


1.
A) Iteration in real life: a factory may experiment with different methods of arranging the
assembly line or with different production methods. Every time the production process is
changed this is a different iteration.
B) Selection: bacteria can become resistant to antibiotics due to natural selection, with the
resistant strains surviving and all the other bacteria dying off.
2.
Harvey James

3.

4.
Harvey James

Chapter 3 questions:
1. Example of a calculation using the arithmetic operators:
Addition: answer = num1 + num2
Subtraction: answer = num1 – num2

Multiplication: answer = num1 * num2

Division: answer = num1 / num2

Modulo operation: answer = num1 MOD num2


Exponentiation: answer = num1 ^ num2
Rounding: answer = Round(num1)
Truncating: answer = Truncate(num1)
Random number generator: answer = Rnd()
2. Dividing an integer may generate a number with a remainder while dividing a real/float
may get a decimal number.
3. Variables tell the program the data type of the values stored inside them so the program
knows how to use them properly.
4. Rounding is replacing the real value with a simpler representation that is close to the
original to the original value. For example 4.567 becomes 4.57 when rounded to 2 decimal
places. Truncating is shortening a value by cutting it off after a certain number of digits. For
example 4.567 becomes 4.56.
5. Random numbers are used to select a random sample from a dataset or to create a range
of test data.
6. OR means a true result is produced if any of the conditions are met while a XOR means a
true result is produced when one or the other condition is met but not both. For example if
you search for a red car with stirpes in an OR operation then it will show red cars, cars with
stripes and red cars with stripes but if it is an XOR then it will show red cars and cars with
stripes but not red cars with stripes.
7. A substring is a string contained within another string. ‘str.substring(Start, End)’ can be
used to extract a substring with ‘Start’ representing the start position and ‘End’ representing
the end position of the substring. The extracted substring can then be stored inside a
variable.
8. Strings can be converted into Integers, Floats and Date-time.
9. Random numbers generated in programing languages are not entirely random because
they use a seed value and an algorithm to create the random number. This makes it not
truly random which makes it inadequate for encryption.
Harvey James

Chapter 3 Study/Research Tasks:


1.

2.
3.
4.
5.
6.

You might also like