Introduction to Programming in Python - Strings - University of Texas ...
Introduction to Programming in Python
Strings
Dr. Bill Young Department of Computer Science
University of Texas at Austin
Last updated: June 4, 2021 at 11:04
Texas Summer Discovery Slideset 10: 1
Strings
Strings and Characters
A string is a sequence of characters. Python treats strings and characters in the same way. Use either single or double quote marks.
letter = 'A'
# same as letter = "A"
numChar = "4"
# same as numChar = '4'
msg = "Good morning"
(Many) characters are represented in memory by binary strings in the ASCII (American Standard Code for Information Interchange) encoding.
Texas Summer Discovery Slideset 10: 2
Strings
Strings and Characters
A string is represented in memory by a sequence of ASCII character codes. So manipulating characters really means manipulating these numbers in memory.
... ... 2000 2001 2002 2003 ... ...
... ... 01001010 01100001 01110110 01100001
... ...
Encoding for character 'J' Encoding for character 'a' Encoding for character 'v' Encoding for character 'a'
Texas Summer Discovery Slideset 10: 3
Strings
ASCII
The following is part of the ASCII (American Standard Code for Information Interchange) representation for characters.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
32
! " # $ %& '
()*+ ,
-
.
/
48
012345 6 7 89 :
; ?
64
@ABCDE F G H I
J K LMNO
80
PQR S TU VWXY Z
[
\
]
96
` abcde f
ghi
j
k
l
mn
o
112 p q r s t u v w x y z { -- }
The standard ASCII table defines 128 character codes (from 0 to 127), of which, the first 32 are control codes (non-printable), and the remaining 96 character codes are representable characters.
Texas Summer Discovery Slideset 10: 4
Strings
Unicode
ASCII codes are only 7 bits (some are extended to 8 bits). 7 bits only allows 128 characters. There are many more characters than that in the world.
Unicode is an extension to ASCII that uses multiple bytes for character encodings. With Unicode you can have Chinese characters, Hebrew characters, Greek characters, etc.
Unicode was defined such that ASCII is a subset. So Unicode readers recognize ASCII.
Texas Summer Discovery Slideset 10: 5
Strings
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- lab manual python programming lab 6cs4 23 jnit
- python basics amazon web services inc
- s˝ˆˇ˘ ncert
- python lists university of michigan
- combining latex with python tex users group tug
- data transformation with cheat sheet github
- introduction to programming in python strings university of texas
- programs on list python class room diary
- p r o g r a m m i n g w i t h p y t h o n university of manchester
- programs list for class xii cs