head of computer science mrs ghalichi-tabriz...•unit h446/03 or h446/04: programming project 20%...
TRANSCRIPT
![Page 1: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/1.jpg)
Mrs Ghalichi-TabrizHead of Computer Science
![Page 2: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/2.jpg)
Introduction• Welcome to the A Level CS Taster Lesson.• The purpose of this lesson is to:
– Explain the structure of the ‘A Level Computer Science’ Course.
– Introduce one of the A Level CS theory topics: representing negative numbers in binary and performing subtraction using two’s complement.
• We hope you’ll enjoy your CS Taster session.A Level CS Teachers:
Mrs Ghalichi-Tabriz & Mr Marks
![Page 3: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/3.jpg)
OCR
A Level Computer Science
Taster Lesson30/06/2020
![Page 4: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/4.jpg)
Key Questions• Understand the structure of the ‘A’ Level Computer
Science Course
• How do you represent negative numbers in binary
• How do you perform subtraction using two’s complement?
![Page 5: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/5.jpg)
OCR A Level Computer ScienceAssessed as follows:
• Unit H446/01: Computer systems 40%
• Unit H446/02: Algorithms and Programming 40%
• Unit H446/03 or H446/04: Programming project 20%
All 3 units are externally assessed
![Page 6: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/6.jpg)
Topic for Taster LessonPaper 1
Topic 1.4.1 Data Types
• Use of sign and magnitude and two’s complement to represent negative numbers in binary
![Page 7: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/7.jpg)
Your Task• Watch ‘Craig N Dave’ video on:
https://www.youtube.com/watch?v=YtMv4u-9poQ&list=RDCMUC0HzEBLlJxlrwBAHJ5S9JQg&
start_radio=1#t=228 • Go through the content of this Google Slide
• Complete ‘CS Taster Lesson Worksheet’• Self assess & reflect on your work against answers
provided for you
![Page 8: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/8.jpg)
Calculating range• Remember that the number of bits determines how
many values can be represented in binary• How many binary values there can be if there are 4 bits used?
• What is the highest and lowest values that can be represented?
0 … 2n - 1
![Page 9: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/9.jpg)
Calculating range - example• If there are 4 bits the range is calculated as
0 … 24 - 1 = 0 … 15
Denary Binary Denary Binary0 0000 8 1000
1 0001 9 1001
2 0010 10 1010
3 0011 11 1011
4 0100 12 1100
5 0101 13 1101
6 0110 14 1110
7 0111 15 1111
![Page 10: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/10.jpg)
Representing negative numbers• How can negative numbers be represented?
• One method is called sign and magnitude
• The first bit acts as the sign, 0 for + and 1 for –
• How would the number -3 be represented in an 8-bit byte using sign and magnitude?
![Page 11: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/11.jpg)
Sign and magnitude• The binary representation of 3 is 00000011
• The binary representation of -3 is 10000011
• Add these two numbers:
• This is -6!
• Clearly arithmetic does not work in the normal way using sign and magnitude
0 0 0 0 0 0 1 1+ 1 0 0 0 0 0 1 1= 1 0 0 0 0 1 1 0
![Page 12: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/12.jpg)
Compliment vs Complement• Compliment - an expression of
praise or admiration
• Complement - a thing that contributes extra features to something else in such a way as to improve or emphasize its quality
![Page 13: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/13.jpg)
Two’s Complement• Negative values are most commonly represented using
a method called two’s complement • Similar to an analogue counter, turning the wheel back 1 will
equal 9999
• Turning back 1 from 00000000 is 11111111
• 11111111 is -1 in binary
![Page 14: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/14.jpg)
Two’s complement• The two’s complement of a signed binary value is
found by flipping all of the bits and adding one
11111101 = -311111110 = -211111111 = -100000000 = 000000001 = 100000010 = 200000011 = 3
![Page 15: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/15.jpg)
Why it works• The two’s complement was used because of the
following principle:
23 00010111 00010111
-23 -??????? -11101001
0 0 0
![Page 16: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/16.jpg)
Most significant Digit• The most significant digit (the left-most digit) is
sacrificed to represent the sign
1 = negative
0 = positive
![Page 17: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/17.jpg)
Signed binary representation• Find -7710 in two’s complement:
• Find the positive value first:
• Flip the bits:
• And add 1:
128 64 32 16 8 4 2 1
0 1 0 0 1 1 0 1 = 77
1 0 1 1 0 0 1 0 = 76
1 0 1 1 0 0 1 1 = -77
![Page 18: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/18.jpg)
An alternative way of doing this• Find -7710 in two’s complement
• The most significant digit becomes -128
-128 + 32 + 16 + 2 + 1 = -77
-128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 1 = -77
![Page 19: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/19.jpg)
Two’s complement range• Note that the number of values that can be
represented is the same as for positive binary numbers
• However, half the range of values now represents negative numbers
• Maximum for 8 bits is 12710 which is 01111111 in binary
• Minimum is -12810 which is 10000000 in binary
-(2(n-1)) … 2(n-1) - 1• What range of values can be represented in16 bits?
![Page 20: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/20.jpg)
Subtraction with two’s complement• Two’s complement can be used to ensure
subtraction will occur when adding negative values
• The calculation 6510 - 4310 should produce the same result as 6510 + - 4310
• This way we can always use addition when we want to subtract
![Page 21: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/21.jpg)
Subtraction with two’s complement128 64 32 16 8 4 2 1
0 1 0 0 0 0 0 1 = 65128 64 32 16 8 4 2 1
0 0 1 0 1 0 1 1 = 43128 64 32 16 8 4 2 1
1 1 0 1 0 1 0 1 = -43
![Page 22: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/22.jpg)
Binary subtraction• Using two’s complement we can find 6510 + -4310
1 1 10 1 0 0 0 0 0 1
+ 1 1 0 1 0 1 0 11 0 0 0 1 0 1 1 0Ignore the
carry bitAnswer is 2210
![Page 23: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/23.jpg)
Two’s complement overflow• Where the result of the addition is too large to fit in
the allocated number of bits, overflow will occur• This is the same as standard binary addition
• If the result requires more bits than are available, the number will not be represented correctly
• A ‘1’ in the left most bit indicates a negative number, therefore overflow occurs above 127 with 8 bits
1 1 0 1 0 1 0 1
![Page 24: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/24.jpg)
Plenary• The fundamental building block of processor
operation is addition
• Negative values use two’s complement in order to be processed correctly without the need for additional processor logic circuits
![Page 25: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/25.jpg)
A Level Preparation (Part 1)Please find below a list of recommended activities for A Level CS preparation:
• 1) Web based programming skills: Students need to develop their web based programming skills including: HTML, CCS and Javascript. They should follow the w3schools.com tutorials in these 3 areas and then complete the project attached here below as a PDF document:
• * Ashlyns students can also access this document in their year 11 (Intake 15 Students) shared drives or Google Classroom : (https://drive.google.com/drive/u/0/folders/1VYQrVfNsHUsO3vE-STVtUh8cZGdldOIF)
• * External students can email the Sixth form team in Ashlyns School and request for a copy of this document.
• 2) Code Academy (Python):
• This course is a great introduction to both fundamental programming concepts and the Python programming language. By the end, you’ll be familiar with Python syntax and you’ll be able to put into practice what you’ll have learned.https://www.codecademy.com/learn/python
![Page 26: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/26.jpg)
A Level Preparation (Part 2)• 3) W3Schools (SQL):
• SQL is a standard language for storing, manipulating and retrieving data in databases. This SQL tutorial will teach you how to use SQL in: MySQL, SQL Server, MS Access, Oracle, Sybase, Informix, Postgres, and other database systems. https://www.w3schools.com/SQL/deFault.asp
• 4) OCR Coding Challenges
• Using Python as a programming language try to complete some of the coding challenges from the following booklets.
• http://www.ocr.org.uk/Images/202838-20-code-challenges.pdf
• http://www.ocr.org.uk/Images/260930-coding-challenges-booklet.pdf
![Page 27: Head of Computer Science Mrs Ghalichi-Tabriz...•Unit H446/03 or H446/04: Programming project 20% All 3 units are externally assessed Topic for Taster Lesson Paper 1 Topic 1.4.1 Data](https://reader030.vdocuments.site/reader030/viewer/2022040621/5f3606e3e9fa9c7c6d1cba8d/html5/thumbnails/27.jpg)
Any Question(s)?• You can always email Mrs Ghalichi-Tabriz if you
have any questions using the following email:• [email protected]
• We hope to see you all in September and wish you a happy and safe summer holidays.
Best wishes
Mrs Ghalichi-Tabriz & Mr Marks