lab02.pdf - lab02 October 8 2018 1 Lab 2 Data Types Welcome to Lab 2 Last time we had our first look at Python and Jupyter notebooks So far weve only

lab02.pdf - lab02 October 8 2018 1 Lab 2 Data Types Welcome...

This preview shows page 1 - 3 out of 8 pages.

21. Review: The building blocks of Python codeThe two building blocks of Python code areexpressionsandstatements. Anexpressionis a piece ofcode that• is self-contained, meaning it would make sense to write it on a line by itself, and• usually has a value.Here are two expressions that both evaluate to 335 - 2One important form of an expression is thecall expression, which first names a function andthen describes its arguments. The function returns some value, based on its arguments. Someimportant mathematical functions areFunctionDescriptionabsReturns the absolute value of its argumentmaxReturns the maximum of all its argumentsminReturns the minimum of all its argumentspowRaises its first argument to the power of its second argumentroundRound its argument to the nearest integerHere are two call expressions that both evaluate to 3abs(2 - 5)max(round(2.8), min(pow(2, 10), -1 * pow(2, 10)))All these expressions but the first arecompound expressions, meaning that they are actuallycombinations of several smaller expressions.2 + 3combines the expressions2and3by addition.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture