Strings Flashcards
Object
A data type that combines state(data) and behaviour(code)
String
Sequences of characters
Unicode
International encoding standard for use with different languages and scripts by which each letter, digit or symbol is represented by a numeric value
ord(“a”)
Return unicode number for 1-character string(97)
chr(97)
returns the 1-character string with unicode symbol
int(“1234”)
Returns integer value
str(1234)
returns the string value
Print 2 variables in order
“{0} {1}.format” (“one”, “two”)
‘one two’
Reverse order
“{1} {0}”.format(“one”, “two”)
‘two one’
align fixed width
“{0:<20}”. format - left
“{0:>20}”.format - right
“{0:^20}”.format - centre
Floating point number rounding
“{0:5.3f}”.format(1.23456789)
‘1.235’
s.count(search)
returns integer number of search strings found within s
s.find(search)
returns position of first search string found within s
s.lower/upper()
return lowercase/uppercase version of s
s.replace(old, new)
Returns version of s with every occurrence of old replaced with new