Strings & Text Flashcards
What is a string?
a sequence of characters
what are characters?
letters, numbers, punctuation marks, spaces
How are string literals specified
enclosing a sequence on characters with either single or double quotations
why are both double and single quotations able to be used?
able to use apostrophe or quotation marks within the string
what is string length?
number of characters in a string
what is the string length function?
len()
how can you convert numbers into a string?
str()
what is string concatenation?
adding one string onto the end of another with “+”
how do you follow nested function calls?
start from inner most to outermost function and substitute values
what is operator overloading? what is an example of it?
operator performs different functions of variables of different types (ex. ‘+’, ‘*’)
what is string repetition function?
“*” repeats a string as many times as indicated:
dashes = “-“*4
–> output: —-
why is it important to have the str() function?
you can now combine numbers with strings (49ers)
what does python use for characters?
unicode –> characters are stored as integer values
what is an index number?
the character’s assigned number, starting with 0
what is index number operator?
[ ]
what is an object?
software entity that represents a value with certain behaviour
–> string, graphical window, data file
what are methods?
behaviour of an object - similar to a function
how is a method different from a string?
methods can only be applied to an object of the type for which it was defined while functions are general and can accept arguments of different types
how do you print a double quote?
before each “ put a “" for the quotation inside
how do you print a backslash?
before \ print another \
do do you output a new line?
\n