{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "$$\n", "\\def\\CC{\\bf C}\n", "\\def\\QQ{\\bf Q}\n", "\\def\\RR{\\bf R}\n", "\\def\\ZZ{\\bf Z}\n", "\\def\\NN{\\bf N}\n", "$$\n", "\\# This file is built automatically; don't edit\n", "\n", "# Code blocks" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "x = 1\n", "no = 'really!'\n", "p = argwhere(x == 2)" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "this = 'is a code block'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "t = linspace(0, 1)\n", "x = t**2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pylab import linspace" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "x = logspace(0, 1)\n", "y = x**2\n", "figure()\n", "plot(x, y)\n", "show()" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pylab import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Support for Python doctest code blocks:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1+1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0\n", "1\n", "2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "for x in range(3):\n", " print x" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = 1\n", "x = 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Sage code blocks\n", "\n", "## Complexité de l'algorithme de tri de Python" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1+1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0\n", "1\n", "2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "for x in range(3):\n", " print x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two sage commands without intermediate output get joined in a single input cell; no output is produced if none is specified:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "1+1\n", "2+2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "3+3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Nested code block A" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ " 1+1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Nested code block B" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ " 1+1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Nested code block C (failing: the inner indent should match the itemized text indent)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " > ```{.python .input}\n", " > 1+1\n", " > ```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**A doubly nested sage code block**\n", "\n", "1. Calculer le plus grand élément d'une liste" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ " 1+1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ " def plus_grand_element(liste):\n", " \"\"\"\n", " Renvoie le plus grand élément de la liste\n", " EXAMPLES::\n", " sage: plus_grand_element([7,3,1,10,4,10,2,9])\n", " 10\n", " sage: plus_grand_element([7])\n", " 7\n", " \"\"\"\n", " resultat = liste[0]\n", " for i in range(1, len(liste)-1):\n", " # Invariant: resultat est le plus grand element de liste[:i]\n", " assert resultat in liste[:i]\n", " assert all(resultat >= x for x in liste[:i])\n", " if liste[i] > resultat:\n", " resultat = liste[i]\n", " return resultat\n", " plus_grand_element([7,3,1,10,4,10,2,9])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " Foo (Failing).\n", "\n", " Bla:\n", "```{.python .input}\n", " 1+1\n", "```\n", "\n", " Don't forget the mandatory new line after \\` ::\\` :: \n", " sage: 1+1\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "> **note**\n", ">\n", "> Blah (Failing):\n", ">\n", "> ```{.python .input}\n", "> 1+1\n", "> ```\n", ">\n", "> Foo (Failing):\n", ">\n", "> ```{.python .input}\n", "> 1+1\n", "> ```\n", "\n", "**Note**\n", "\n", "Blah:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "1+1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Foo:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "1+1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Complexité de l'algorithme de tri de Python\n", "\n", "**Exercice**\n", "\n", "1. Estimer la complexité de la fonction suivante" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " :\n", "\n", " sage: def fusion(l1, l2): ....: sort(l1+l2)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Images\n", "\n", "\"image\"\n", "\n", "# List\n", "\n", "### Bullets\n", "\n", "- b1\n", "- b2\n", "- b3\n", "\n", "### List\n", "\n", "1. l1\n", "2. l2\n", "3. l3\n", "\n", "# Math\n", "\n", "Inline maths with math role: $x^3+\\frac{1+\\sqrt{2}}{\\pi}$\n", "\n", "Inline maths with default role: $x^3+\\frac{1+\\sqrt{2}}{\\pi}$\n", "\n", "Inline maths using dollar signs (not supported yet): \\$x^3+frac{1+sqrt{2}}{pi}\\$\n", "\n", "$$x^3+\\frac{1+\\sqrt{2}}{\\pi}$$\n", "\n", "# Quote\n", "\n", "> This is a quote!\n", "\n", "# Table\n", "\n", "A simple table:\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
C1C2
ab
cd
\n", "\n", "A table with more formatting:\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
C1C2
ab
cd
\n", "\n", "# Topics\n", "\n", "**Definition**\n", "\n", "Hello, this is a block definition\n", "\n", "Some more text\n", "\n", "1. An enumeration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " **Note**\n", "\n", " A nested topic within the enumeration within a topic\n", "\n", " Back to the item\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Next item\n", "\n", "# Links\n", "\n", "A link: [images](images.ipynb)\n", "\n", "rst2ipynb implements some very crude support for ref links; the links below will point to $images.ipynb$, allowing at least to refer to other documents in the same directory without hardcoding the .ipynb extension in the source file.\n", "\n", "- [images](images.ipynb)\n", "- [Les Images](images.ipynb)" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 2 }