Week 2 Glossary#
Here we provide a short glossary of important syntax features and functions of python that you should know after this week.
Syntax features:#
+: operator for adding two numbers, or for concatenating two strings-: operator for subtraction*: operator for multiplication, and also for string repetition/: operator for “true division”//operator for “floor division”%: operator for remainder**: operator for exponentiation(): for overriding operator precedence and for supplying arguments to function calls#: indicating the start of comments (lasting until the end of line)==: operator for “equal to” comparisons!=: operator for “unequal to” comparisons>: operator for “greater than” comparisons<: operator for “less than” comparisons>=: operator for “greater than or equal to” comparisons<=: operator for “less than or equal to” comparisonsand: operator to join two logical statements with an “and”or: operator to join two logical statements with an “or”not: operator to negate a logical statementinandnot in: operator to check if a string is (or is not) contained in anotheris Noneandis not None: check if a variable is (or is not)None[]: for indexing or slicing a python list:: for constructing a slice object of the form start:stop:step
Built-in python functions:#
print(): print out valuesabs(): absolute value of a numbermax(): maximum between a sequence of numbersmin(): minimum between a sequence of numbersround(): rounding a number to fixed number of decimal placesbool(): convert an object to a boolean value, if possiblefloat(): convert an object to a floating point number, if possibleint(): convert an object to an integer, if possiblestr(): convert an object to a string, if possibletype(): determine the type of an objectlen(): find the length of a python list
List methods:#
.append(): append an element to a list.extend(): extend a python list using another list.index(): Find the first index of a list in which a value occurs