{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial A1 – Solutions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "__1__ Get your hands on a working installation of Python 3, install Jupyter, and open the exercise solution template." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*Task 1 is completed successfully as this notebook is running.*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "__2__ Make Python put a Greeting on the screen (fill in your own name) and comment your code!\n", " \n", " Hello, ! How's your day?" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello, Iggy! How's your day?\n" ] } ], "source": [ "print(\"Hello, Iggy! How's your day?\")\n", "# A friendly greeting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "__3__ Make Python raise a `SyntaxError` and a `NameError`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "unexpected EOF while parsing (, line 1)", "output_type": "error", "traceback": [ "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m ( # raises SyntaxError\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m unexpected EOF while parsing\n" ] } ], "source": [ "( # raises SyntaxError" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'a' is not defined", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m \u001b[1;31m# raises NameError\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mNameError\u001b[0m: name 'a' is not defined" ] } ], "source": [ "a # raises NameError" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }