{"nbformat": 3, "worksheets": [{"cells": [{"source": ["Let's evaluate some simple expressions."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["6"], "output_type": "pyout", "metadata": {}, "prompt_number": 1}], "collapsed": false, "language": "python", "input": ["3*2"], "cell_type": "code", "metadata": {}, "prompt_number": 1}, {"outputs": [{"text": ["11"], "output_type": "pyout", "metadata": {}, "prompt_number": 2}], "collapsed": false, "language": "python", "input": ["5+3*2"], "cell_type": "code", "metadata": {}, "prompt_number": 2}, {"source": ["You can use `type()` to find the *type* of an expression."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["int"], "output_type": "pyout", "metadata": {}, "prompt_number": 3}], "collapsed": false, "language": "python", "input": ["type(5+3*2)"], "cell_type": "code", "metadata": {}, "prompt_number": 3}, {"source": ["Now add decimal points."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["12.0"], "output_type": "pyout", "metadata": {}, "prompt_number": 4}], "collapsed": false, "language": "python", "input": ["5+3.5*2"], "cell_type": "code", "metadata": {}, "prompt_number": 4}, {"outputs": [{"text": ["float"], "output_type": "pyout", "metadata": {}, "prompt_number": 5}], "collapsed": false, "language": "python", "input": ["type(5+3.0*2)"], "cell_type": "code", "metadata": {}, "prompt_number": 5}, {"source": ["Strings are written with single (``'``) or double quotes (`\"`)"], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["'hello'"], "output_type": "pyout", "metadata": {}, "prompt_number": 6}], "collapsed": false, "language": "python", "input": ["\"hello\""], "cell_type": "code", "metadata": {}, "prompt_number": 6}, {"source": ["Multiplication and addition work on strings, too."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["'hellohellohelloeagpggpu'"], "output_type": "pyout", "metadata": {}, "prompt_number": 7}], "collapsed": false, "language": "python", "input": ["3 * 'hello' + \"eagpggpu\""], "cell_type": "code", "metadata": {}, "prompt_number": 7}, {"source": ["Lists are written in brackets (`[]`) with commas (`,`)."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["[5, 3, 7]"], "output_type": "pyout", "metadata": {}, "prompt_number": 8}], "collapsed": false, "language": "python", "input": ["[5, 3, 7]"], "cell_type": "code", "metadata": {}, "prompt_number": 8}, {"source": ["List entries don't have to have the same type."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["['hi there', 15, [1, 2, 3]]"], "output_type": "pyout", "metadata": {}, "prompt_number": 9}], "collapsed": false, "language": "python", "input": ["[\"hi there\", 15, [1,2,3]]"], "cell_type": "code", "metadata": {}, "prompt_number": 9}, {"source": ["\"Multiplication\" and \"addition\" work on lists, too."], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 5, 5, 5]"], "output_type": "pyout", "metadata": {}, "prompt_number": 10}], "collapsed": false, "language": "python", "input": ["[1,2,3] * 4 + [5, 5, 5]"], "cell_type": "code", "metadata": {}, "prompt_number": 10}, {"source": ["Hmmmmmm. Was that what you expected?"], "metadata": {}, "cell_type": "markdown"}, {"outputs": [{"text": ["array([ 9, 13, 17])"], "output_type": "pyout", "metadata": {}, "prompt_number": 11}], "collapsed": false, "language": "python", "input": ["import numpy as np\n", "\n", "np.array([1,2,3]) * 4 + np.array([5,5,5])"], "cell_type": "code", "metadata": {}, "prompt_number": 11}], "metadata": {}}], "metadata": {"name": "", "signature": "sha256:1d4638f04ac9bebb506d31c12b56a2df066953fc0dc2af8367456f67edb7c94a"}, "nbformat_minor": 0}