{ "metadata": { "name": "", "signature": "sha256:9fac4f2f7be1f3f3d74c894c65a436ff0907fcd16fc3e3cdfc6656189de3cde0" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# The Format Method\n", "\n", "- **Author:** [Chris Albon](http://www.chrisalbon.com/), [@ChrisAlbon](https://twitter.com/chrisalbon)\n", "- **Date:** -\n", "- **Repo:** [Python 3 code snippets for data science](https://github.com/chrisalbon/code_py)\n", "- **Note:**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create some variables" ] }, { "cell_type": "code", "collapsed": false, "input": [ "name = 'Chris'\n", "age = 24" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Print a string that uses the other variables\n", "0 and 1 representing the 1st and second variables in the format() list) inside of it." ] }, { "cell_type": "code", "collapsed": false, "input": [ "'{0} is {1} years old.'.format(name, age)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 3, "text": [ "'Chris is 24 years old.'" ] } ], "prompt_number": 3 } ], "metadata": {} } ] }