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” comparisons

  • and: 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 statement

  • in and not in: operator to check if a string is (or is not) contained in another

  • is None and is 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 values

  • abs(): absolute value of a number

  • max(): maximum between a sequence of numbers

  • min(): minimum between a sequence of numbers

  • round(): rounding a number to fixed number of decimal places

  • bool(): convert an object to a boolean value, if possible

  • float(): convert an object to a floating point number, if possible

  • int(): convert an object to an integer, if possible

  • str(): convert an object to a string, if possible

  • type(): determine the type of an object

  • len(): 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