{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# An introduction to solving biological problems with Python\n", "\n", "## Day 1 - Session 1: Variables\n", "\n", "- [Printing values](#Printing-values)\n", "- [Exercises 1.1.1](#Exercises-1.1.1)\n", "- [Using variables](#Using-variables)\n", "- [Exercises 1.1.2](#Exercises-1.1.2)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Printing values\n", "\n", "The first bit of python syntax we're going to learn is the print statement. This command lets us print messages to the user, and also to see what Python thinks is the value of some expression (very useful when debugging your programs).\n", "\n", "We will go into details later on, but for now just note that to print some text you have to enclose it in \"quotation marks\". \n", "\n", "We will go into detail on the arithmetic operations supported in python shortly, but you can try exploring python's calculating abilities." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "print(\"Hello from python!\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "print(34)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "print(2 + 3)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "You can print multiple expressions you need to seperate them with commas. Python will insert a space between each element, and a newline at the end of the message (though you can suppress this behaviour by leaving a trailing comma at the end of the command)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [], "source": [ "print(\"The answer:\", 42)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To start the Python interpreter, open a terminal window, type the command `python3`, then enter Python commands after the prompt `>>>` and press `Enter` when you're done. \n", "\n", "
