[go: up one dir, main page]

0% found this document useful (0 votes)
30 views20 pages

T4 Ascii

The document discusses representing characters using ASCII encoding: - ASCII uses 7-bit binary codes to represent 128 characters, including letters, numbers, and symbols. Each character is assigned a unique 7-bit code. - There are more than 128 characters used on keyboards, so 7 bits are needed to sufficiently represent all required characters. - Characters like letters have assigned codes; for example, the code for A is 65 in decimal or 01000001 in binary. Performing arithmetic on character codes can cause issues.

Uploaded by

xhbcyhhnvc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views20 pages

T4 Ascii

The document discusses representing characters using ASCII encoding: - ASCII uses 7-bit binary codes to represent 128 characters, including letters, numbers, and symbols. Each character is assigned a unique 7-bit code. - There are more than 128 characters used on keyboards, so 7 bits are needed to sufficiently represent all required characters. - Characters like letters have assigned codes; for example, the code for A is 65 in decimal or 01000001 in binary. Performing arithmetic on character codes can cause issues.

Uploaded by

xhbcyhhnvc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Objectives

• Understand how computers encode characters using


7-bit ASCII
• Be able to convert characters to and from ASCII
• Understand the limitations of binary representation of
characters when constrained by the number of available bits
ASCII
Unit 2 Data

Starter
• A computers memory and storage only hold binary
1s and 0s
• How might it be possible to store letters with only binary?
ASCII
Unit 2 Data

Representing text characters


• If a computer understands only 1s and 0s, what
happens when the ‘M’ key is pressed on the
keyboard?

0 1 0 0 1 1
0 1
ASCII
Unit 2 Data

Representing characters
in binary
• Every character on the keyboard is represented by a
binary value
• Uppercase letters (capitals) have different values from lowercase
characters
• Punctuation symbols have their own character code

• How many characters are there on a standard


keyboard?
• How many bits would be required to represent this many
combinations?
ASCII
Unit 2 Data

Characters in binary
• A keyboard needs to contain
• 26 lowercase letters
• 26 uppercase letters
• 10 numbers
• (around) 36 other characters

• There are around 98 unique characters that are


available on a keyboard
• 6 bits give 64 different combinations – this isn’t enough
• 7 bits give 128 different combinations which can represent
128 different characters
ASCII
Unit 2 Data

Character sets
• A character set is a set of letters, symbols and digits
that can be represented by a computer
• There are two major character sets in use today
• ASCII
• Unicode

• ASCII uses 7-bits for each character, whilst


extended-ASCII uses 8-bits
• For Edexcel you only need know about 7-bit ASCII
ASCII
Unit 2 Data

The ASCII character set


• ASCII (American Standard Code for Information
Interchange) has become the standard code, used
worldwide
• It was originally developed in the 1960s for representing the
English alphabet
• It encodes 128 characters into 7-bit binary codes

• Characters include numbers 0 to 9, uppercase and


lowercase letters A-Z, a-z, punctuation symbols and
the space character
ASCII
Unit 2 Data

The ASCII character set


• What happens if you press ALT+65 on a keyboard?
• What character is represented by 0100000 (32)?

• What is the ASCII character for the number 7? Is this


the same as the binary value for 7?
• Why not? What is happening? What does this mean?
ASCII
Unit 2 Data

ASCII groups and sequences


• Character codes are commonly grouped and run in
sequence
• Numeric characters 0 to 9 run consecutively from 48 to 57 on
the ASCII table
• A-Z characters are from 65-90 or
1000001 to 1011010
• What range does lowercase characters a-z use?
• If you know Capital A is 65 or 1000001, what is Capital E?
ASCII
Unit 2 Data

ASCII character set


• ASCII character 32 (010 0000) represents a space
• The ASCII character code for ‘7’ is 55
• 55 (011 0111) is the ASCII character code that represents the
character ‘7’
• In programming this is very different to the integer 7 which is
represented by 0000 0111 (7)
• Lowercase characters a-z use 97-122
• If A is 65 (100 0001) then E is 69 (100 0101)
ASCII
Unit 2 Data

Worksheet 4
• Complete Task 1 on Worksheet 4
ASCII
Unit 2 Data

Programming with text


and numbers
• The ASCII code for ‘7’ is 011 0111
• The binary code for the digit 7 is 0000 0111

• When you write a program in Python, for example,


you have to specify whether a variable is text or
integer
• You cannot do arithmetic with characters
• If the character represents a number it must first be converted
to an integer before any arithmetic can be carried out
ASCII
Unit 2 Data

Working with string input


• In Python, two strings can be concatenated, or
joined together, using the + symbol
firstname = input("Please input your first name: ")
secondname = input("Please input your second name: ")
fullname = firstname + " " + secondname
print("Your full name is " + fullname)

• If you enter Mike for a first name and Bell for a


second name, the computer will display
Your full name is Mike Bell
ASCII
Unit 2 Data

ASCII representation
of numbers
• Try typing ALT + 55
• What is the binary representation of the ASCII
character 7? Is this the same as the binary value for 7?
• Why not? What does this mean?
ASCII
Unit 2 Data

Converting ASCII to pure binary


• Clearly, we cannot do arithmetic with ASCII characters
• Programming languages deal with the input of
numbers in different ways
• In some languages, variables have to be declared as
type char, string, integer, real etc., at the beginning of
the program
• In other languages such as Python, all data is input as string, and
if it is to be regarded as an integer, it has to be converted using
an inbuilt function
e.g. xString = input("Enter an
integer: ")
x = int(xString)
ASCII
Unit 2 Data

Worksheet 4
• Complete Task 2 on Worksheet 4
ASCII
Unit 2 Data

Plenary
• Work in a pair to answer the
following questions
• How many bits are required for
each ASCII character?
• How many characters does this
allow for?
• If ‘f’ has the ASCII code 102, what
is the ASCII code for ‘g’?
• How many bytes are needed to
store “Hello everyone.”?
ASCII
Unit 2 Data

Plenary
• How many bits are required for each ASCII character? 8 bits
• How many characters does this allow for? 256
• If ‘f’ has the ASCII code 102, what is the ASCII code for ‘g’?
103
• How many bytes are needed to store “Hello everyone.”?
15 letters (remember space and the full stop)
ASCII
Unit 2 Data

Copyright

© 2020 PG Online Limited

The contents of this unit are protected by copyright.

This unit and all the worksheets, PowerPoint presentations, teaching guides and other associated files
distributed with it are supplied to you by PG Online Limited under licence and may be used and copied by you
only in accordance with the terms of the licence. Except as expressly permitted by the licence, no part of the
materials distributed with this unit may be used, reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, electronic or otherwise, without the prior written permission of PG Online Limited.

Licence agreement

This is a legal agreement between you, the end user, and PG Online Limited. This unit and all the worksheets,
PowerPoint presentations, teaching guides and other associated files distributed with it is licensed, not sold, to
you by PG Online Limited for use under the terms of the licence.

The materials distributed with this unit may be freely copied and used by members of a single institution on a
single site only. You are not permitted to share in any way any of the materials or part of the materials with any
third party, including users on another site or individuals who are members of a separate institution. You
acknowledge that the materials must remain with you, the licencing institution, and no part of the materials may
be transferred to another institution. You also agree not to procure, authorise, encourage, facilitate or enable any
third party to reproduce these materials in whole or in part without the prior permission of PG Online Limited.

You might also like