introduction to a level maths at mggs · web viewpython will determine the data type depending on...

64
Flying start: Computer Science

Upload: others

Post on 11-Feb-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

INTRODUCTION TO A LEVEL MATHS AT MGGS

Flying start: Computer Science

Planner 

The following plan is meant as a guide to help you structure the activities in this flying start pack between June and August.  

You can work at your own pace and spend less or more time on each activity. 

For programming, ROUTE A is for those with programming experience, and ROUTE B is for those with no programming experience.

Week and activity number 

Page number 

Time allocation 

Complete? 

Week 1: Task 1 – Hello World

Route A – 2Route B – 14

30 Minutes

 

Task 2 – Sequence

Route A – 3Route B – 16

90 Minutes 

 

Week 2: Task 3 - Variables

Route A - 5 Route B – 18

120 Minutes 

 

Week 3: Task 4 – Constants & Inputs

Route A – 8Route B – 21

90 Minutes 

 

Week 4: Task 5 - Selection

Route A – 10Route B – 23

120 Minutes 

 

Week 5: Task 6 - Repetition

Route A -  12Route B – 26

120 Minutes

 

Week 6: Task 7 – Bits & Bytes

 29

 90 Minutes

 

Week 7: Task 8 – Types of Number

 32

 90 Minutes

 

Week 8: Task 9 – Binary

 34

 90 Minutes

 

Week 9: Task 10 – Hexadecimal

 38

 90 Minutes

 

Week 10: Task 11– Assessment

 41

 60 Minutes

 

Programming Skills – Route A

This route is for student who have studied Computer Science at GCSE or have programming experience.

Task 1 – Hello World

The first tasks for learning any programming language is to create a ‘Hello World’ program. You currently have some programming experience, so use the language you are most comfortable with. If you can’t install the language onto your computer, you could look for an online version from the table below:

Language

Link

Python

https://www.onlinegdb.com/online_python_compiler

https://www.jdoodle.com/python3-programming-online/

Visual Basic

https://www.onlinegdb.com/online_vb_compiler

https://www.jdoodle.com/compile-vb-dot-net-online/

Small Basic

https://superbasic-v2.azurewebsites.net/

QBasic

https://repl.it/languages/qbasic

Java

https://www.compilejava.net/

https://www.jdoodle.com/online-java-compiler/

repl.it, onlinegdb, and jdoodle have many other languages available.

Copy your Hello World code into the table below, and fully explain your code.

Code

Explanation

Some languages will require you to create a program structure around your task, if this is the case can you also explain these lines of code also.

Task 2 - Sequence

Every programming language is created using just three key concepts (Constructs). Examining these concepts will not only teach you how to program, but you will also gain an important deeper knowledge which will allow you to be more independent.

1) Research ‘Sequence Programming Construct’.

2) Complete the definition below:

Definition

3) Explain why it is important:

Why is it important?

4) What is the implication for the programmer?

Implications

Examples

5) Write a program to output the following rows of stars:

****************

Copy your code into the table below, and fully explain your code.

Code

Explanation

6)Write a program to output the following Menu:

**** My System Menu **************************** 1: Load Data ** 2: Save Data ** 3: Clear Data ** 4: Run System ** 5: Exit System ************************

Copy your code into the table below, and fully explain your code.

Code

Explanation

Task 3 - Variables

A variable is used to store a value within a program, the value stored can be changed while the program is running by the code. Variables can then be used in calculations and can also be used to determine the path of your program.

Different languages handle variables slightly differently, in most languages you have to specify what type of data the variable will hold. Python will determine the data type depending on the data stored, it will even allow you to change the type of data stored.

1) Research ‘Sequence Programming Variables’.

2) Explain why they are need below:

Why Variables

3) What is a Data Type

Definition

4) Explain the following Data Types (include examples):

String

Integer

Boolean

Char

Float, Real, Double etc

Examples

5) Write a program which creates the following variables:

Variable

Data Type

Value

FirstName

String

Joe

LastName

String

Bloggs

Age

Integer

21

Initial

Char

A

Glasses

Boolean

True

Now, using your variables, create the following output:

‘Hello my name is {FirstName} {Initial} {LastName}, I am {Age} years of age, and it is {Glasses} that I wear glasses.’

The { } brackets indicate where your variable should go, and which should be used for each position.

Copy your code into the table below, and fully explain your code.

Code

Explanation

6) Write a which creates the following variables:

Variable

Data Type

Value

Item

String

“Tape Measure”

Price

Float, Real, Double etc

4.50

Quantity

Integer

50

VAT

Float, Real, Double etc

0.20

Now, using your variables, create the calculations:

ItemTotal = Price * QuantityVATTotal = ItemTotal * VATFinalTotal = ItemTotal + VATTotal

Now create the following output:

{Item}{Quantity} x £ {Price} = {ItemTotal}VAT = {VAT}Final Total = {Final Total}

The { } brackets indicate where your variable should go, and which should be used for each position.

Copy your code into the table below, and fully explain your code.

Code

Explanation

Task 4 – Constants & Input

A constant is just like a variable and is used to store a value within a program, the value stored however cannot be changed while the program is running. The only way to change the value of a constant is to change the value in the code.

1) Identify some examples of constants, and their value:

Constant Examples

2) Even though it can change VAT is often created as a constant, why?

VAT as a Constant

Examples

3) Investigate if your programming language can use Constants, if so copy an example here:

Constant Example

4) Create the following program, copy it into the space provided and explain:

Declare a constant for PI, and give it the value 3.141

Create a variable for Radius, and give it the value 9

Calculate RadiusSq, by multiplying Radius by itself.

Calcuate Area, by multiplying RadiusSq by PI

Finally output- ‘The area of a circle with a radius of {Radius} is {Area}’

Code

Explanation

Variables allow the programmer to perform calculations, however without the ability to read in a value from the user the calculations will be less useful.

Each programming language will provide a way to read in a value from the keyboard.

5) Investigate how to read a value from the keyboard and store it as a variable

6) Copy an example of the code into the space below:

Input Example

7) To use the input in a calculation you may need to convert the input into a numerical value. Provide an example in the space below:

Input Convert Example

Examples

8) Create the following program, copy it into the space provided and explain:

Declare a constant for PI, and give it the value 3.141

Create a variable for Diameter, and allow the user to input a value

Calculate Circumference, by multiplying Diameter by PI

Create the final output:

‘The Circumference of a circle with a diameter of {Diameter} is {Circumference}’

Code

Explanation

Task 5 – Selection

You have already learnt the first programming concept / construct (Sequence). The next concept is Selection, this is the ability for your program to take different paths based on some condition.

1) Research ‘Selection Programming Construct’.

2) Complete the definition below:

Definition

3) Explain why it is important:

Why is it important?

4) What is the implication for the programmer?

Implications

5) Copy an example for an IF statement:

IF

6) Copy an example of an IF .. ELSE .. statement

IF ELSE

7) Copy an example of an IF .. ELSEIF .. ELSE statement

IF

ELSE IF

ELSE

8) How can your IF have 2 conditions?

IF with 2 conditions

Examples

9) Create the following program, copy it into the space provided and explain:

Create a variable for Mark, and allow the user to input a value (assume 0-100 only)

Create a variable for Message, and give it an initial value of “ “

Create an IF statement to check if Mark is less than 40, If true Message = “Fail”

Create the ELSE, and add Message = “Pass”

Create the final output:

‘A Mark of {Mark} is a {Messgae} grade’

Code

Explanation

10) Extend your previous program, copy it into the space provided and explain:

Copy your program from above, you currently have an IF .. ELSE .. statement that we will expand to include more grades.

Between your IF and ELSE sections add an ELSE IF, check if the Mark is less than 60. If true make Message = Pass.

Next add another ELSE IF to check if Mark is less than 80. If true make Message = Merit

Finally edit your ELSE condition to make Message = Distinction.

Code

Explanation

Task 6 – Repetition / Iteration

You have already learnt the first two programming concept / construct (Sequence & Selection). The next concept is Repetition, this is the ability for your program to repeat a block of code either a given number of times or until a condition is met.

1) Research ‘Repetition Programming Construct’.

2) Complete the definition below:

Definition

3) Explain why it is important:

Why is it important?

4) What is the implication for the programmer?

Implications

There are 3 types of repetition:

5) FOR which loops a given number of times, copy an example into the space below:

For

6) WHILE which checks the condition and will loop if true, once completed it will check again. copy an example into the space below:

While

7) DO WHILE (or Repeat) will run all of the code once and then check the condition, copy an example into the space below:

Do While / Repeat

Examples

8) Create the following program, copy it into the space provided and explain:

Create a variable for Number, and allow the user to input a value (assume 0-100 only)

Create a FOR loop to run 10 times, the loop should:

Create a variable Answer, set the value to Number * Loop Count

Output {Loop Count} x {Number} = {Answer}

Code

Explanation

9) Create the following program, copy it into the space provided and explain:

Create a variable for Number, and set the value to be -1

Create a WHILE loop, set the condition to be while Number is not equal to -1.

The loop should:

Read the value from the keyboard, and store it using Number

Create an IF statement, check if UserInput is greater than 0 AND less than 100

Output the input is valid

Create an ELSE

Change Number back to -1

Code

Explanation

Programming Skills – Route B

This route is for student who haven’t studied Computer Science at GCSE or have no programming experience.

Task 1 – Hello World

The first tasks for learning any programming language is to create a ‘Hello World’ program. You currently have no programming experience, so we are going to use Python and instead of installing it onto your computer we can use one of the online versions below:

JDOODLE - https://www.jdoodle.com/python3-programming-online/

Your output will appear here

This is the code panel, it will already have some python commands entered. You can delete any existing code and enter your own code here.

Click Execute to run your code

ONLINEGDB - https://www.onlinegdb.com/online_python_compiler

Click Run to execute your code

Your output will appear below this section while your code is running

This is the code panel, it will already have some python commands entered. You can delete any existing code and enter your own code here.

PROGRAMIZ - https://www.programiz.com/python-programming/online-compiler/

This is the code panel, it will already have some python commands entered. You can delete any existing code and enter your own code here.

Your output will appear here

Click Run to execute your code

Task

Using one of the online sites, add the following command:

print("Hello World")

The print() command in python will write the text within the speech marks to the screen.

Remember Python is case sensitive so it is important to be precise with your coding

Now try the following:

print ()

Result

Now try the following:

print ("Hello", end="")

print ("World")

Result

Task 2 - Sequence

Every programming language is created using just three key concepts (Constructs). Examining these concepts will not only teach you how to program, but you will also gain an important deeper knowledge which will allow you to be more independent.

1) Research ‘Sequence Programming Construct’.

2) Complete the definition below:

Definition

3) Explain why it is important:

Why is it important?

4) What is the implication for the programmer?

Implications

Examples

5) Write a program to output the following rows of stars (use print() for each line):

****************

Python uses indentation so make sure each line has no spaces before your commands.

Copy your code into the table below, and fully explain your code.

Code

Explanation

6)Write a program to output the following Menu (use print() for each line):

**** My System Menu **************************** 1: Load Data ** 2: Save Data ** 3: Clear Data ** 4: Run System ** 5: Exit System ************************

Python uses indentation so make sure each line has no spaces before your commands.

Copy your code into the table below, and fully explain your code.

Code

Explanation

Task 3 - Variables

A variable is used to store a value within a program, the value stored can be changed while the program is running by the code. Variables can then be used in calculations and can also be used to determine the path of your program.

Different languages handle variables slightly differently, in most languages you have to specify what type of data the variable will hold. Python will determine the data type depending on the data stored, it will even allow you to change the type of data stored.

1) Research ‘Sequence Programming Variables’.

2) Explain why they are need below:

Why Variables

3) What is a Data Type

Definition

4) Explain the following Data Types (include examples):

String

Integer

Boolean

Float, Real, Double etc

In Python, a variable can be created by giving a variable name and assigning it a value with = , So:

VariableName = Valueprint(VariableName)

Remember the value for a string will need to be in quote marks, and a Boolean should be True or False. Python will also determine the data type for you and you don’t need to provide one. The second line shows that you can print any variable by using the variable inside the ( ) or the print.

The print() command can only print a string, so if your variable is not a string you will need to convert it. This can be done using str():

VariableName = 10

print( str( VariableName ) )

You can also use int() to convert to an integer, this will be required to convert the data entered by a user to an integer. You can also use float() to convert to a float or real number.

Examples

5) Write a program which creates the following variables:

Variable

Data Type

Value

FirstName

String

Joe

LastName

String

Bloggs

Age

Integer

21

Initial

Char

A

Glasses

Boolean

True

Now, using your variables, create the following output:

‘Hello my name is {FirstName} {Initial} {LastName}, I am {Age} years of age, and it is {Glasses} that I wear glasses.’

The { } brackets indicate where your variable should go, and which should be used for each position.

Copy your code into the table below, and fully explain your code.

Code

Explanation

6) Write a which creates the following variables:

Variable

Data Type

Value

Item

String

“Tape Measure”

Price

Float, Real, Double etc

4.50

Quantity

Integer

50

VAT

Float, Real, Double etc

0.20

Now, using your variables, create the calculations:

ItemTotal = Price * QuantityVATTotal = ItemTotal * VATFinalTotal = ItemTotal + VATTotal

Now create the following output:

{Item}{Quantity} x £ {Price} = {ItemTotal}VAT = {VAT}Final Total = {Final Total}

The { } brackets indicate where your variable should go, and which should be used for each position.

Copy your code into the table below, and fully explain your code.

Code

Explanation

Task 4 – Constants & Input

A constant is just like a variable and is used to store a value within a program, the value stored however cannot be changed while the program is running. The only way to change the value of a constant is to change the value in the code.

1) Identify some examples of constants, and their value:

Constant Examples

2) Even though it can change VAT is often created as a constant, why?

VAT as a Constant

In Python the convention for constants is to declare them in capitals:

CONSTANT = Value

print(CONSTANT)

However this doesn’t prevent you from changing its value while the program is running. This is a limitation of Python and is something which makes programming simpler but the trade off is a lack of features from other languages.

Examples

3) Create the following program, copy it into the space provided and explain:

Declare a constant for PI, and give it the value 3.141

Create a variable for Radius, and give it the value 9

Calculate RadiusSq, by multiplying Radius by itself.

Calcuate Area, by multiplying RadiusSq by PI

Finally output- ‘The area of a circle with a radius of {Radius} is {Area}’

Code

Explanation

Variables allow the programmer to perform calculations, however without the ability to read in a value from the user the calculations will be less useful.

Each programming language will provide a way to read in a value from the keyboard. In Python this is achieved using the input() command:

Name = input("Enter your name")

print("hello " + Name)

The quotes within the ( ) of the input will be displayed as a prompt. The user can then enter some data and press the enter key. In the example above the data entered will be stored in a variable called Name.

Remember you may need to convert the data entered, ie int() to convert the input to an integer and float() to convert it to a float / real number.

Examples

4) Create the following program, copy it into the space provided and explain:

Declare a constant for PI, and give it the value 3.141

Create a variable for Diameter, and allow the user to input a value

Calculate Circumference, by multiplying Diameter by PI

Create the final output:

‘The Circumference of a circle with a diameter of {Diameter} is {Circumference}’

Code

Explanation

Task 5 – Selection

You have already learnt the first programming concept / construct (Sequence). The next concept is Selection, this is the ability for your program to take different paths based on some condition.

1) Research ‘Selection Programming Construct’.

2) Complete the definition below:

Definition

3) Explain why it is important:

Why is it important?

4) What is the implication for the programmer?

Implications

In Python, you can use the following example of an if statement:

age = int( input("Please enter your age:") )

if age >= 18 :

print("You are old enough to drink")

You start with the command if, followed by the condition (in this case age is greater than or equal to 18). The condition should equate to True or False, if it is true it will run the code attached to this if statement. The colon, : is the end of the condition. From this point everything to run if true should be indented.

The following operators are used in Python:

You can also provide and else statement and code for any if statement, have a look at this example:

age = int( input("Please enter your age:") )

if age>=18 :

print("You are old enough to drink")

else :

print("you are not old enough to drink")

Notice that the code to run if true is indented, and the code to run if false is also indented. The if else statement can run as many lines of code as required, each line will need to be indented to the same level.

You can also use elif in an if statement, it is short for else if. In the example below, if the first condition is true it will display the message "You are over the age of 21". if the first condition is false, it will move to the next condition and if this is false it will move to the else.

age = int( input("Please enter your age") )

if age >= 21:

print("You are over the age of 21")

elif age >= 18:

print("You are over 18 but not yet 21")

else:

print("You are under 18")

Examples

5) Create the following program, copy it into the space provided and explain:

Create a variable for Mark, and allow the user to input a value (assume 0-100 only)

Create a variable for Message, and give it an initial value of “ “

Create an IF statement to check if Mark is less than 40, If true Message = “Fail”

Create the ELSE, and add Message = “Pass”

Create the final output:

‘A Mark of {Mark} is a {Messgae} grade’

Code

Explanation

6) Extend your previous program, copy it into the space provided and explain:

Copy your program from above, you currently have an IF .. ELSE .. statement that we will expand to include more grades.

Between your IF and ELSE sections add an ELIF, check if the Mark is less than 60. If true make Message = Pass.

Next add another ELIF to check if Mark is less than 80. If true make Message = Merit

Finally edit your ELSE condition to make Message = Distinction.

Code

Explanation

Task 6 – Repetition / Iteration

You have already learnt the first two programming concept / construct (Sequence & Selection). The next concept is Repetition, this is the ability for your program to repeat a block of code either a given number of times or until a condition is met.

1) Research ‘Repetition Programming Construct’.

2) Complete the definition below:

Definition

3) Explain why it is important:

Why is it important?

4) What is the implication for the programmer?

Implications

There are 3 types of repetition:

FOR - which loops a given number of times, this example will start at 1, and finish with the value of 10:

for i in range(1,11):

print(i)

WHILE - which checks the condition and will loop if true, once completed it will check again. copy an example into the space below:

i=0

while i<10:

i=i+1 # could use i++ instead

print("i is "+i)

One of the key things to notice is that a for loop has a built in counter, where as you need to create one in your while loop.

A for loop should be used if the code needs to run a given number of times. A while loop should be used if you don’t know how many times the loop needs to repeat. A while loop will check the condition first, so if the condition is False from the start it won’t run.

DO WHILE (or Repeat) - will run all of the code once and then check the condition. Python doesn’t have a loop of this type, you will need to use a while and make it check the condition again before it restarts:

loopcontrol = true

while loopcontrol:

print("Password System")

password = input("Please enter the password")

if password == "itsjustme":

loopcontrol = false

Examples

5) Create the following program, copy it into the space provided and explain:

Create a variable for Number, and allow the user to input a value (assume 0-100 only)

Create a FOR loop to run 10 times, the loop should:

Create a variable Answer, set the value to Number * Loop Count

Output {Loop Count} x {Number} = {Answer}

Code

Explanation

6) Create the following program, copy it into the space provided and explain:

Create a variable for Number, and set the value to be -1

Create a WHILE loop, set the condition to be while Number is not equal to -1.

The loop should:

Read the value from the keyboard, and store it using Number

Create an IF statement, check if UserInput is greater than 0 AND less than 100

Output the input is valid

Create an ELSE

Change Number back to -1

Code

Explanation

TASK 7 – Bits & Bytes

A bit is the fundamental unit of information. A bit represents a single 1 or a single 0. The term bit is derived from the term “Binary Digit”. Each bit can represent 1 or 0, on or off, true or false, open or closed. These options are very limited, so bits are grouped together into bytes.

A byte is a pattern of 8 bits for example 10101011 or 01001100 or 01111010. A byte could be used to represent an individual character (see ASCII work later), a numerical value and so on.

Beyond the Byte

The term Kilobyte originally referred to 1024 bytes, and this was derived from the fact that 210 equals 1024. However in 1996 it was decided that this system was too complicated and a system based around a kilobyte equalling 1000 bytes (103) should be used. Complete the tables below:

Name

Symbol

Power

Kilo

KB

MB

GB

TB

1015

1018

1021

1024

Name

Symbol

Power

Kibi

KiB

MiB

GiB

TiB

250

260

270

280

Character Codes

ASCII is the most used character code, it stands for American Standard Code for Information Interchange. It takes 7 bits to store each character, which gives sufficient combinations (127) to store all the keyboard characters, some control and communication codes. The ASCII set was extended to 8 bits to also allow an extended character set for non-keyboard characters (256).

The upper case letters form a sequence from 65 (‘A’) to 90 (‘Z’).

The lower case letters form a sequence from 97 (‘a’) to 122 (‘z’).

The digits have values 48 (‘0’) to 57 (‘9’).

Examples:

‘C’ has the ASCII code 67

‘h’ has the ASCII code 104

‘5’ has the ASCII code 53

What do these ASCII codes represent?? (i) 13 (ii) 8 (iii) 10

Find the ASCII code for these characters:

(i) R(ii) r(iii) 9(iv) £

(v) B(vi) 5(vii) z(viii) .

Unicode is different coding system and is becoming more common. It is a 16-bit code, giving enough combinations to store every character in every alphabet (e.g. Urdu, Chinese) plus a vast range of other characters, control and communication codes.

Extended ASCII

These are the added ASCII values allowed by the change from 7 bit to 8 bit ASCII.

The added characters contain characters to create an interface or menu.

8 bit ASCII supports double the number of characters, which allows more language support but not anywhere near those supported by Unicode.

The 16-bit code can represent 65536 different characters.

It maintains compatibility with ASCII by using the same code values as ASCII (ie codes 0-255 are the same as the ASCII table). So if you take ‘z’ and its ASCII value 122 (0111 1010 in binary), the unicode value is still 122 the binary will be 0000 0000 0111 1010.

Task 8 – Types of Number

A number is used to show the quantity of things. The use of numbers have developed out of the need to quantify posessions or belongings. For example a farmer would make a notch in a stick for each cow currently in given field. The concept of zero is a more recent development, there was little need for zero because if a farmer had no sheep to count then he didn’t count then. At some point we have identified a need to document the lack of something or the need to be able to identify when we have nothing.

The representation of a number is called a numeral. Numerals are written symbols for numbers. You will have come across the roman numeral system for example, Or the Arabic numerals we all use.

Explain the following types of number, and remember to include a list of the number set:

Natural Numbers

Definition:

Number Set:

Rational Numbers

Definition:

Number Set:

Irrational Numbers

Definition:

Number Set:

Real Numbers

Definition:

Number Set:

Ordinal Numbers

Definition:

Number Set:

Task 9 – Binary Number System

Explain the Binary Number System:

To convert from binary to denary – place value method

Simply add up the column values for those columns where a binary 1 appears:

e.g. 1) 10101

column value16 8 4 2 1

number 1 0 1 0 1

16

4

1+

21

1 0 1 0 1represents 16 + 4 + 1 = 21 in denary

Another example:

e.g. 2)1101101

column value 64 32 16 8 4 2 1

number 1 1 0 1 1 0 1

64

32

8

4

1+

109

1101101 represents 64 + 32 + 8 + 4 + 1 = 109 in denary

Convert these values:

1111111 =

10000000 =

11011 =

100101 =

To convert from denary to binary – place value method

Start at the left hand side, placing 1’s in the appropriate columns to make up the number

e.g. 1) 123 =

64 32 16 8 4 2 1

1 1 1 1 0 1 1

So 123 in denary represents 1111011 in binary

e.g. 2) 29 = 16 8 4 2 1

1 1 1 0 1

So 123 in denary represents 11101 in binary

e.g. 3) 63 = 32 + 16 + 8 + 4 + 2 + 1 = 111111 (or more easily by realising 64 - 1 = 63)

Convert the following:

13=

48=

31=

127=

76=

To convert from denary to binary – repeated division method

The number to be converted is repeatedly divided by 2, writing down the remainders each time, until the result is 0. The final 1 and remainders are then read in the order shown to give the answer.

e.g.Convert 123 to 8-bit binary

Read final 1 & then remainders upwards

The answer is 1111011

This method works when converting from denary to any other number base, simply replace the division by 2 by the base number required.

Note: Binary numbers are often represented using a set number of bits such as 8-bit (byte) notation (or multiples of 8). Simply add leading 0’s if you are asked to do this.

Use the repeated division method to calculate the following in binary:

77=

109 =

Task 10 – Hexadecimal Number System

Explain the Hexadecimal Number System:

To convert from hex to denary – place value method

e.g. 2F4= 2x256 = 512

15x16 = 240

4x1 = 4 +

756

Remember the least significant place value is 1, and each place value multiplies the previous by 16

To convert from denary to hex – place value method

e.g. 1000=3x256 + 14x16 + 8=3E8

To convert from denary to hex – repeated division method (divide by 16)

e.g.Convert 12345 to hex

The answer is 3039

Convert the following to hexadecimal:

3505=

707=

4600=

177=

808=

8008=

Convert the following to denary:

FF=

12A=

ABC=

1DAD=

Conversion between binary and hex

4 binary digits can be represented by 1 hex digit

To change a binary number directly to hex, split the binary number into groups of 4 bits, from the right, and write down the hex equivalent of each group.

e.g. 01011111

5F

01011111 = 5F

00111101=

10110001=

Note – if the number of bits is not a multiple of 4 then you can add 0’s to the left hand end if necessary.

Conversion between hex and binary

This method works equally well for hex to binary

e.g. B 4

10110100

B4= 10110100

CA=

4D=

Task 11 – Assessment

Programming

1) State the THREE programming constructs used by all programming languages:

-----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------

2) Explain your first construct:

-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

3) Explain your second construct:

-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

4) Explain your Third construct:

-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------

Bits & Bytes

Character Coding Systems

Types of Number

Binary Number System

Hexadecimal Number System

(2)