Lecture 5 Flashcards
escape character, lambda functions, and maps
escape character + function
\
Reads the preceding character as a command rather than part of the string
\n
new line
horizontal tab using escape character
\t
types a tab key amount of space
carriage return (esc char) + function
\r
tells Python to move the cursor back to the beginning of the current line. So, when you execute this line, Python first prints “Hello”, then when it encounters \r, it moves the cursor back to the beginning of the line and continues printing. It then prints “World”.
back space (esc char) + function
\b
Moves the active position to the previous position on the current line
form feed (esc char) + fxn
\f
Form feed is a page-breaking ASCII control character. It forces the printer to eject the current page and to continue printing at the top of another
vertical tab (esc char) + fxn
\v
Prints the text next to it in a new line after a tab space
single and double quotes (esc char)
\’ and \”
backslash symbol (esc char)
\
lambda function (2) + syntax
- a small anonymous function.
- can take any number of arguments, but can only have one expression
lambda arguments : expression
maps (2) + syntax
A standard function that accepts at least two arguments, a function (ANY function) and an iterable
runs the lambda for each value in the iterable and returns a MAP OBJECT, which can be converted into another data structure
syntax:
typecast(map(function, iterable))
abs() function
returns absolute value of the input