Decisions in Python Comparing Strings – ASCII History.

Slides:



Advertisements
Similar presentations
Review of HTML Ch. 1.
Advertisements

Review Ch.1,Ch.4,Ch.7. Review of tags covered various header tags Img tag Style, attributes and values alt.
James Tam Beyond Base 10: Non-decimal Based Number Systems What exactly is decimal? How do other number systems work (binary, octal and hex) How to convert.
Using Binary Coding Information Remember  Bit = 0 or 1, Binary Digit  Byte = the number of bits used to represent letters, numbers and special characters.
Is ASCII the only way? For computers to do anything (besides sit on a desk and collect dust) they need two things: 1. PROGRAMS 2. DATA A program is a.
Chapter 8_2 Bits and the "Why" of Bytes: Representing Information Digitally.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
מבנה מחשב תרגול 2 ייצוג תווים בחומרה. A programmer that doesn’t care about characters encoding in not much better than a medical doctor who doesn’t believe.
28-Jun-15 Number Systems. 2 Bits and bytes A bit is a single two-valued quantity: yes or no, true or false, on or off, high or low, good or bad One bit.
Data Representation (in computer system) Computer Fundamental CIM2460 Bavy LI.
Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child.
COMPUTER FUNDAMENTALS David Samuel Bhatti
ASCII and Unicode. ASCII Inside a computer, EVERYTHING is a number – that includes music, sound, and text. In the early days of computers, every manufacturer.
Lesson Objectives Explain the use of binary codes to represent characters Explain the term “Character set” Describe with examples (for examples ASCII and.
CODING SYSTEMS CODING SYSTEMS CODING SYSTEMS. CHARACTERS CHARACTERS digits: 0 – 9 (numeric characters) letters: alphabetic characters punctuation marks:
2.1.4 BINARY ASCII CHARACTER SETS A451: COMPUTER SYSTEMS AND PROGRAMMING.
Computer Systems Nat 4/5 Computing Science Data Representation Lesson 3: Storing Text.
Unicode, character sets, and a a little history. Historical Perspective First came EBCIDIC (6 Bits?) Then in the early 1960s came ASCII – Most computers.
CHARACTERS Data Representation. Using binary to represent characters Computers can only process binary numbers (1’s and 0’s) so a system was developed.
Representing text Each of different symbol on the text (alphabet letter) is assigned a unique bit patterns the text is then representing as.
File Formats Chapter 9 Bit Literacy. File formats are often ignored by users Applications automatically save files in the application’s format All formats.
Fill in the blanks: (1) _________ has only two possible values 0 and 1. (2) There are __________bits in a byte. (3) 1 kilobyte of memory space can store.
More Binary How does a computer represent everything using just zeros and ones?
Examples of comparing strings. “ABC” = “ABC”? yes “ABC” = “ ABC”? No! note the space up front “ABC” = “abc” ? No! Totally different letters “ABC” = “ABCD”?
SEC (1.4) Representing Information as bit patterns.
Computer Science Binary. Binary Code Remember the power supply that is inside your computer and how it sends electricity to all of the components? That.
Representing Characters in a computer Pressing a key on the computer a code is generated that the computer can convert into a symbol for displaying or.
Chapter Three The UNIX Editors.
The Information School of the University of Washington Oct 13fit digital1 Digital Representation INFO/CSE 100, Fall 2006 Fluency in Information Technology.
The Information School of the University of Washington 15-Oct-2004cse digital1 Digital Representation INFO/CSE 100, Spring 2005 Fluency in Information.
M204 - Data Representation
ASCII AND EBCDIC CODES By : madam aisha.
Representing Characters in a Computer System Representation of Data in Computer Systems.
Information Coding Schemes Group Member : Yvonne Tiffany Jurifah bt Junaidi Clara Jane George.
Millions of electronic pulses move through your computer every second. Computers are capable of processing thousands of functions in the time it takes.
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
1.4 Representation of data in computer systems Character.
Lecture Coding Schemes. Representing Data English language uses 26 symbols to represent an idea Different sets of bit patterns have been designed to represent.
Nat 4/5 Computing Science Data Representation Lesson 3: Storing Text
DATA REPRESENTATION - TEXT
Binary Representation in Text
Binary Representation in Text
CS 101 History and Basics.
Unit 2.6 Data Representation Lesson 2 ‒ Characters
Binary 1 Basic conversions.
Data Transfer ASCII FILES.
How does a computer represent everything using just zeros and ones?
BITS & BYTES.
Guide To UNIX Using Linux Third Edition
Breaking the Code Can anyone guess the phrase from this “code”?
Representing Information as bit patterns
Data Encoding Characters.
TOPICS Information Representation Characters and Images
Lecture 3 ISE101: Computing Fundamentals
Representing Characters
Data Representation Question: Characters
How does a computer represent everything using just zeros and ones?
Comparing Strings – How to
BITS & BYTES.
Fundamentals of Data Representation
Presenting information as bit patterns
COMS 161 Introduction to Computing
COMS 161 Introduction to Computing
Digital Encodings.
Learning Intention I will learn how computers store text.
Beyond Base 10: Non-decimal Based Number Systems
C Programming Language
ASCII LP1.
Lecture 36 – Unit 6 – Under the Hood Binary Encoding – Part 2
ASCII and Unicode.
Presentation transcript:

Decisions in Python Comparing Strings – ASCII History

Comparing strings Comparing numbers is easy, how do you compare strings? Remember that everything inside the computer is a number – yes, everything! So every character on the keyboard (and more) are represented as a number inside Does that mean you have to memorize a lot of numbers to compare strings? No!

Comparing strings If the operator is ==, then the strings have to be exactly identical – same spacing, same case, everything has to be the same to give a True (!= gives a False then) If the operator is one of the other relational operators, how do you tell if one string is less than another? greater than? By using their ASCII codes!

ASCII American Standard Code for Information Interchange Early computer manufacturers each had their own code for characters Users didn’t care as long as it worked, until they wanted to share / trade / sell information with someone who had a different brand of computer

ASCII Some small companies made a living translating data from one company’s code to another The computing community decided they needed a standard code for characters for all computers Having one helps the Internet send messages between dissimilar computers Other codes were considered but ASCII was the winner in the mid 1960’s ASCII has 256 codes, each character takes up 1 byte

ASCII ASCII is designed so that the alphabetic characters are in numeric order also. So ‘A’ < ‘B’ < ‘C’ < ‘D’ < … < ‘Z’ Other characters: the lower case alphabetic characters are also in numeric order ‘a’ < ‘b’ < ‘c’ < ‘d’ < … < ‘z’ The lower case letters come after the upper case letters in ASCII – an arbitrary decision

ASCII What about digits? ‘0’, ‘1’, ‘2’, ‘3’, …? They have codes also. ASCII is designed so those digits are also in numeric order ‘0’ < ‘1’ < ‘2’ < ‘3’ < … < ‘9’ The codes for the digits are less than the upper case letters – an arbitrary decision Just one more! ‘ ‘ = 1 space, is the lowest printable character, lower than all the other characters discussed

ASCII Summary of the order you should know First comes the space character Then the digits ‘0’ ‘1’ ‘2’ ‘3’ ‘4’ ‘5’ ‘6’ ‘7’ ‘8’ ‘9’ Then the upper case ‘A’, ‘B’, ‘C’, ‘D’, … ‘Z’ Then the lower case ‘a’, ‘b’, ‘c’, ‘d’, …, ‘z’ There are other characters in the code – control codes, punctuation, etc. you do NOT have to know any of those.

Unicode For a while ASCII’s 256 codes was sufficient. It contained the English (Roman) alphabet, digits and some pnc. What about other countries / languages? Eventually it was decided that a code that could represent more languages’ symbols had to be created. Unicode came about in the 90’s – first 256 characters are the ASCII code Each character takes up 2 bytes (or more!) so Unicode has at least 65 thousand character codes

What does Unicode mean to me? It takes up more room than a plain ASCII text file, which means more room on your HD, more time uploading and downloading As a programmer, you may run into “wide characters” or “fat characters” which will require different libraries / methods to handle If you get documents in foreign languages, you will be better able to get them translated correctly (Unicode does not do translation!)