Docsity

AQA Computer Science Cheat Sheet, Cheat Sheet of Computer Science

Partial preview of the text

Download AQA Computer Science Cheat Sheet and more Cheat Sheet Computer Science in PDF only on Docsity!

AQA Computer Science

Computer Science @ Kingswinford

AQA COMPUTER SCIENCE

CHEAT SHEET GUIDES TO SUPPORT LEARNING

BY MRS FRANKS

AQA Computer Science

Computer Science @ Kingswinford

AQA COMPUTER SCIENCE

CHEAT SHEET GUIDES TO SUPPORT LEARNING

This cheat sheet book has been created to support learning in AQA Computer Science lessons. It is not endorsed by AQA in any way. However, they have commented about my resources on twitter:

This guide goes through each topic in the AQA scheme for learning. The guides are designed to jog your memory or explain things in a simple manner so that the concepts can be grasped.

They do not cover ALL the aspects of AQA computer science. Lessons should go into much more depth than in this book. They are just an aid to support learning. There are 35 topics and these are listed below in the order of this book:

1. Computer Systems 13. Bespoke Data Structures 24. Input and Output Devices 2. Expressions and Types 14. Software Development Life Cycle 25. Prototyping and Testing 3 3. Constants and Variables 15. Prototyping and Testing 1 26. Algorithm 4. Selection 16. Bits and Bytes 27. Language Libraries 5. Repetition 17a. Binary 28. External Databases TEXT 6. Boolean Operators 17b. Hexadecimal 29. External Databases SQL 7. Arrays 18. Character Sets 30. Networks 8. Flowcharts 19. Sound 31. Client Server Model 9. Trace Tables 20. Bitmap Images 32. Client Side Programming 10. Errors 21. Instructions and the CPU 33. Server Side Programming 11. Functions and Procedures 22. Memory 34. External Code Sources 12. Scope 23. Secondary Storage 35. Computer Technology in Society

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3. Unported License.

Topic 2 :: Expressions and Types

Define: Expressions

“A combination of precise values, constants, variables, operators, and

functions that are interpreted according to the particular rules of priority”

Define: Types

“Also known as a data type, it is the name used to describe the different

types of data used in a program”

What are values, variables, operators and functions?

We will learn much more about these later on. But here is a quick

explanation.

Value = a value

Constants = something that stays the same

Variables = something that changes depending on a condition

Operators = +, - , *, /, power (these are the main ones)

Function = A portion of code within a larger program

What data types do the following belong to?

1 Yes abc 3.4 No

Don’t know? Find out!

Common Primitive Data Types

Numbers Characters Logical

Integers Real Numbers

byte short int long float double char Boolean

Topic 3 :: Constants and Variables

Define: Constant

“As the word suggests. A constant is something that stays the same

throughout the program”

Define: Variable

“A variable changes throughout the program depending on certain

conditions”

Constants are useful for making your code simpler. Also, once you have declared the constant, it can be changed by the programmer if required. Declaring the constant at the start means that you don’t have to go through the entire program, changing each occurrence in turn.

E.g. A game was designed where the constant speed of the character was set to 5. After testing the game, the user thought the speed wasn’t challenging enough so the programmer changed the constant speed to 10. Once defined, a constant remains the same throughout the execution of the application/game.

Variables are used when a value needs to change during the execution of the program.

E.g. A game has a scoring system. When the character shoots a target, 1 is added to the score. Score is a variable ; it changes every time a target is hit. If a value changes within a program then it is called a variable.

So constants remain the same and variables change. Got it!

My speed is constant! It never changes.

My score changes every time I get a question right. So it’s a variable!

Topic 5 :: Repetition

Define: Repetition

“Repetition is used when the same bit of code is needed several

times. Instead of writing it over and over again, you can use the repeat

command. Repetition can also be called looping.”

The three most common loops are a FOR loop, a WHILE loop or a REPEAT UNTIL loop.

FOR FOR i ← 1 TO 5 OUTPUT i ENDFOR

this will output: 1, 2, 3, 4 and 5

WHILE (^) WHILE myVar ≠ 100 OUTPUT myVar myVar ← myVar + 1 ENDWHILE

REPEAT UNTIL REPEAT

OUTPUT “Enter a number” num ← INPUT OUTPUT num UNTIL num = 5

10 green bottles sitting on the wall, 10 green bottles sitting on the wall, and if 1 green bottle should accidently fall. There’ll be 9 green bottles sitting on the wall.

Hold on a minute, why am I repeating myself?

For as long as the variable i is 1,2,3,4 or 5. Display the variable i. (each time this loop runs it will add 1 to i)

While the variable myVar is not equal to 100, output the variable myVar and reduce myVar by 1.

Repeat the command, “Enter a Number” until the number 5 has been typed in.

Topic 6 :: Boolean Operators

Define: Boolean Operators

“Boolean operators are AND, OR or NOT. Boolean operators can

be used in a Boolean expression. The result of a Boolean expression is

always TRUE or FALSE. Arithmetic operators (<,<=, ==,!=, >=,>) can

also be used to create Boolean values (TRUE or FALSE). ”

Yippee!

Let’s play a sorting game!

Circle the shapes that are black AND have straight edges.

Well done! Now circle the shapes that are white OR round.

Super! Now circle the shapes that are NOT squares.

Miss, that was too easy!

I’m glad you find it so easy. Now tell me if these arithmetic expressions create the Boolean value TRUE or FALSE.

Arithmetic Expression TRUE OR FALSE?

12 > 9 TRUE

3 * 6 < 23 TRUE

22 != 2 * 11 FALSE

35 == 7 * 4 FALSE

99 < 98 FALSE

COVER

CHECK!

Topic 8 :: Flowcharts

Define: Flowcharts

“Flowcharts are used to plan out a procedure using a diagram”

Why so many You need to learn the^ symbols? meaning of all the symbols below.

Start or Stop

E.g. product ID, barcode, name, option choice, email address.

E.g. calculations, saving, printing, anything that HAPPENS!

Any question with a Yes or No response.

E.g. customer details, invoice, payment details.

Start / Stop (terminators)

Input box

Process

Decision box

Storage

E.g. a receipt, an invoice, certificate, report.

Printed output

Topic 9 :: Trace Tables

Define: Trace Tables

“This is a method that we can use for testing whether our code

makes sense logically”

It is sensible to use a trace table in the design stage of your program.

 Break down your code into steps.  Each step should be a row in your trace table.  Each row should show the “state” of your variables for that step.

But I am always logical?

This may be the case but when you make a program it is not always easy to spot logic errors. So we use trace tables to spot the things we may not!

Oh!

I have made this one for my “Shoot the Balloons” game. It tracks the score at each stage. When the balloon is hit, the user scores 10 points. Have I done it right?

Balloon Hits Score 0 0 1 10 2 20 3 30 4 40 5 50 6 60

Yes, this is a good example of a simple trace table. They will become more complex as you learn more about programming.

Programming languages allow you to trace variables in the console when running your code. It is important to learn how to do this for each programming language that you use.

Topic 11 :: Functions and Procedures

Define: Functions and Procedures

“Functions and procedures are quite similar as they are bits of

code that can be recalled at any point in your program and used again

and again”

The Difference:

A procedure just “does something” A function returns a value

OR in even more simple terms...

So procedures “do something” and functions “return a value”

Brushing your teeth is a procedure. You perform the same routine every day. E.g. put toothpaste on brush, brush teeth for two minutes, spit, and clean brush. These actions can all come under the procedure name “Brushing my Teeth”. Once the routine has finished there is no value to return, it has just finished.

Counting your computer games is a function. You look at your pile of games, you count them all and you are left with a value. Every time you count your games you do the same routine, add 1 each time, and at the end you are left with a value.

Yes, the value doesn’t have to be a number though. It could be string, characters or anything really!

Topic 12 :: Scope

Define: Scope

“This refers to where a variable is accessible in your code”

Different Types of Scope:

Any variable declared within a module can be accessed and modified by any

procedure within that module.

Any variable declared within a project can be accessed and modified by any

procedure or module within that project.

Any variable declared as global can be accessed and modified by any procedure,

module or project within the program.

You can’t see me because I was declared INSIDE the procedure.

If I use a variable inside a procedure, can I use it Only if it has been declared as a global variable. For a variable to somewhere else in my code?

be accessible anywhere, it needs to be defined as a global variable at the beginning of your code.

Procedure Scope

Module Scope

Project Scope

Global Scope

Hello, I am looking for the Name variable?

Procedure Scope is where a variable is declared inside a procedure.

Topic 14 :: Software Development Life Cycle

Define: Software Development Life Cycle

“This is the different phases or stages that we need to go through

in order to make a successful program”

Analyse

Design

Implement

Test

Evaluate

Maintain

But I just want to get started and write my code! It is good that you are keen but you do need to go through all of the steps or else you will make a lot of work for yourself when things go wrong!

Analyse – What does your program need to do?

Design – What will it look like?

Implement – Let’s code it!

Test – Does it work?

Evaluate – Does it work effectively?

Maintain – Does it still work now it is being used for real?

Topic 15 :: Prototyping and Testing 1

Define: Prototyping and Testing 1

“Throughout this course you will be set programming tasks. The

level of skill required will increase for each one. They will always cover

elements that have been covered in your Computer Science lessons”

What you should know by now:

Expressions and Types Variables and Constants Selection

Repetition Boolean Operators Arrays

Flow Charts Trace Tables Errors

Functions and Procedures Scope Bespoke Data Structures

Software Development Life Cycle

Yay I get to make something! Yes, and remember to follow the Software Development Life Cycle whilst doing this!

Project: You have two weeks to complete this project. You should use lesson

time to ask your peers to assess your progress.

Brief: A primary school teacher wants her students to learn how to spell the

list of words below. You must develop a program that allows students to test

their spelling. Be as imaginative as you like with this!

When What Kneel Knight Knock Honest Which Witch Middle Paddle Bottle

Travelled Terrible Frustrating Dancing Evaporate Stopped Wreck Dough

Though Through

Topic 17a :: Binary

Define: Binary

“Binary is a machine language made of 0’s and 1’s. The 0

represents OFF and the 1 represents ON”

We (humans) understand numbers as denary; our numbers have a base of 10.

Computers understand binary; binary has a base of 2. In order to communicate with

computers, binary numbers are converted to denary.

This is how denary works...When we write the number 483,297 we are looking at

where those numbers are placed on the number scale.

The symbol ^ means “to the power of”. This should be familiar to you!

10^7 10^6 10^5 10^4 10^3 10^2 10^1 10^

or (4 * 100,000) + (8 * 10,000) + (3 * 1000) + (2 * 100) + (9 * 10) + (7 * 1)

Let’s say we have the binary number 01001010 and we need to convert it to

denary. We can do this using a table to help us. Each binary digit holds a place.

Like denary is 10 to the power of..., Binary is 2 to the power of...

2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^

OFF ON OFF OFF ON OFF ON OFF

When we put our binary number into our table we can begin to convert the number to

denary. Wherever there is a 1, we count the value that applies to the placeholder.

We can only ever multiply the placeholder by 1 or 0. 0 is ignored as you can see!

How computers think

How humans think

Topic 17b :: Hexadecimal

Define: Hexadecimal

“This is a word used to describe a number that has a base of 16.

Similar to binary that has a base of 2 and denary that has a base of 10.”

Two examples of where hexadecimal is used in terms of computer science are:

 Colour References – Colours are assigned a hexadecimal number, for

example, white is represented as #FFFFFF

 Error Messages – You may have seen an error message on your screen that

displays something like “error reading FFFF-1048”, this refers to a specific

error that can be located using the hexadecimal number

Hexadecimal has 16 values. These compared to decimal can be seen below:

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

When we want to convert from Hexadecimal to Decimal (or denary) we can use the

table below, this shows how the Hex number D48 is converted:

16^7 16^6 16^5 16^4 16^3 16^2 16^1 16^

D 4 8

If we place D48 on our number scale we can work out the denary conversion by

looking at where the numbers are placed.

We complete the following calculation:

(8 * 1) + (4 * 16) + (D * 256)

We know that D = 13 from the conversion table above. So this calculation becomes:

Giving us the conversion: 3400