Worksheet 02 - Introduction To ASCII Table and Python

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Worksheet 02 – Introduction to ASCII table and Python

Full name: Aim: Try


some Python
programming.

HEX is a code, a short-hand way of writing binary. Every HEX symbol represents FOUR bits of binary.

0 1 2 3 4 5 6 7 8 9 A B C D E F
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

This ASCII table is internationally agreed table for sending messages. For example, a short massage “Hello, today is 8/12/2022”
H e l l o , (space) t o d a y i s 8
0100 0110 0110 0110 0110 0010 0010 0111 0110 0110 0110 0111 0010 0110 0111 0010 0011
1000 0101 1100 1100 1111 1100 0000 0100 1111 0100 0001 1001 0000 1001 0011 0000 1000

When we hit the <ENTER> key on our keyboard, the binary code 0000 1101 is sent from the KB to the computer.
When someone hit the digit ‘8’, the KB sends ‘0011 1000’. This is called THE STRING representation of the digit ‘8’. Its
binary equivalent is 0000 1000.
As strings, ‘8’ + ‘8’ = ‘88’
As binary, 8 + 8 = 16

CoP046 – Algorithms & Programming: Python ORB Education. Visit www.orbeducation.com for a range of quality teaching resources.
A demonstration of the difference between STRING and INTEGER
num_1=input("Enter first digit:")
Who’s done?
num_2=input("Enter second digit:")
Answer: Andrew Nguyen, Tony Nguyen,Eric
print("As strings: ",num_1+num_2) La,Kayla Kim Nguyen, John( Linh) Nguyen,Jessica
(Anh) Ngo,Nathan Do, Daniel Bobadilla, Kevin
print("As numbers: ",int(num_1)+int(num_2))
Hang, Tina lavea, Nyanbuot , Lyna Nguyen, Kathy
Notes: Do, Ray Duong
 the function int(num_1) only works when
num_1 is a series of digits, not characters.
 Use the function float() to handle numbers with
decimal point
 We can’t add + a string and an integer

CoP046 – Algorithms & Programming: Python ORB Education. Visit www.orbeducation.com for a range of quality teaching resources.

You might also like