diff --git a/Exercises/solutions/gap_exercise3_if_else.ipynb b/Exercises/solutions/gap_exercise3_if_else.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..6bf7f47582825e9ad0018392fe5b8b0b8de0dbcf --- /dev/null +++ b/Exercises/solutions/gap_exercise3_if_else.ipynb @@ -0,0 +1,211 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "gap_exercise3_if_else.ipynb", + "provenance": [], + "collapsed_sections": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Python course - Exercises Gap text" + ], + "metadata": { + "id": "kH0p2uT-sQ6y", + "pycharm": { + "name": "#%% md\n" + } + } + }, + { + "cell_type": "markdown", + "source": [ + "Correct the Code" + ], + "metadata": { + "id": "uW9SoYEyrlRL", + "pycharm": { + "name": "#%% md\n" + } + } + }, + { + "cell_type": "code", + "source": [ + "# complete the statement for b larger than a\n", + "a = 5\n", + "b = 10\n", + "\n", + "if b > a:\n", + " print('b larger a')" + ], + "metadata": { + "id": "uoscfCSCK980", + "pycharm": { + "name": "#%%\n" + }, + "outputId": "9b383eb8-a957-4975-9ece-bdebb1bbf55e", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 1, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "b larger a\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# complete the statements\n", + "a = 5\n", + "b = 10\n", + "c = 5\n", + "\n", + "if(a < b) and (a == c):\n", + " print('a smaller b, but a equals c')" + ], + "metadata": { + "id": "9DGKzqxWdABE", + "pycharm": { + "name": "#%%\n" + }, + "outputId": "eeb99a8a-426d-4a9f-fc6a-bf035e67b31d", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "a smaller b, but a equals c\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# complete the statements\n", + "a = 5\n", + "b = 10\n", + "c = 5\n", + "\n", + "if a <= c:\n", + " print('a smaller or equal c')\n", + "elif a >= b:\n", + " print('a larger or equal b')" + ], + "metadata": { + "id": "3ipcaNRCdv9S", + "pycharm": { + "name": "#%%\n" + }, + "outputId": "96acdcd0-91e1-443b-b6de-7f6a95239a91", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "a smaller or equal c\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# complete the statements\n", + "a = 5\n", + "b = 10\n", + "c = 5\n", + "\n", + "if a != c:\n", + " print('a not c')\n", + "elif a == b:\n", + " print('a equals b')\n", + "else:\n", + " print('None of the above is true')" + ], + "metadata": { + "id": "w9QBlM8Hel_u", + "pycharm": { + "name": "#%%\n" + }, + "outputId": "5c9c3e63-7ec3-417d-c08d-f9f8ee6f9b92", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "None of the above is true\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# complete the statements\n", + "a = 5\n", + "b = 10\n", + "c = 5\n", + "\n", + "if (a != c) or (b != c):\n", + " print('a not c OR b not c')\n", + "else:\n", + " print('None of the above is true')" + ], + "metadata": { + "id": "5KfDsRHLfW7k", + "pycharm": { + "name": "#%%\n" + }, + "outputId": "7d073833-18cf-4de7-9814-f3d422642b4b", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "a not c OR b not c\n" + ] + } + ] + } + ] +} \ No newline at end of file