From c495cffc34407429a5c32352a43af6c64c09c124 Mon Sep 17 00:00:00 2001 From: albabalcells Date: Wed, 24 Jun 2020 20:18:54 +0200 Subject: [PATCH 01/12] variables defined --- .gitignore | 67 +++++++++++++++ your-project/Code.ipynb | 185 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+) create mode 100644 .gitignore create mode 100644 your-project/Code.ipynb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603c50e --- /dev/null +++ b/.gitignore @@ -0,0 +1,67 @@ +# Created by https://www.toptal.com/developers/gitignore/api/jupyternotebooks,macos,microsoftoffice +# Edit at https://www.toptal.com/developers/gitignore?templates=jupyternotebooks,macos,microsoftoffice + +### JupyterNotebooks ### +# gitignore template for Jupyter Notebooks +# website: http://jupyter.org/ + +.ipynb_checkpoints +*/.ipynb_checkpoints/* + +# IPython +profile_default/ +ipython_config.py + +# Remove previous ipynb_checkpoints +# git rm -r .ipynb_checkpoints/ + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### MicrosoftOffice ### +*.tmp + +# Word temporary +~$*.doc* + +# Word Auto Backup File +Backup of *.doc* + +# Excel temporary +~$*.xls* + +# Excel Backup File +*.xlk + +# PowerPoint temporary +~$*.ppt* + +# Visio autosave temporary files +*.~vsd* + +# End of https://www.toptal.com/developers/gitignore/api/jupyternotebooks,macos,microsoftoffice \ No newline at end of file diff --git a/your-project/Code.ipynb b/your-project/Code.ipynb new file mode 100644 index 0000000..3fb037f --- /dev/null +++ b/your-project/Code.ipynb @@ -0,0 +1,185 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "GAME STRUCTURE\n", + "\n", + "1. Introduce game \n", + "2. Ask for level of difficulty (input)\n", + " a. Easy: 1-10, 5 turns\n", + " b. Medium: 1-100, 7 turns\n", + " c. Hard: 1-1000, 11 turns\n", + " *capitalize letter of input, allow only these 3 options!!!! (message if not)\n", + " \n", + "3. Assign variables in function of level chosen (if function): numbers (list), tries (integer)\n", + "4. Print text explaing the game in function of the level\n", + "\n", + "Game\n", + "\n", + "5. Generate right_number (random variable)\n", + "6. Ask for user's input, name it guess_number\n", + "7. While loop, given number of tries the user can do\n", + "8. Function that returns \"Low\" or \"High\" depending on if the number is high or low, and returns \"Correct!\" if the number is correct\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "Ask if the want to play again. If they want, maybe keep track of the rounds they have won and failed????\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "levels=[\"easy\", \"medium\", \"hard\"]\n", + "def ask_level():\n", + " choice=input(\"Pick your level: easy, medium or hard? \").lower()\n", + " while choice not in levels:\n", + " print(\"Please, choose one of the options: easy, medium or hard\")\n", + " choice=input(\"\\nPick your level: easy, medium or hard? \").lower()\n", + " return choice" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pick your level: easy, medium or hard? easy\n" + ] + } + ], + "source": [ + "level=ask_level()" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pick a number between 1 and 10. You have 5 turns. Let's play!\n" + ] + } + ], + "source": [ + "numbers=[]\n", + "if level==\"easy\":\n", + " for i in range(1,11):\n", + " numbers.append(i)\n", + " tries=5\n", + " print(\"Pick a number between 1 and 10. You have 5 turns. Let's play!\")\n", + "elif level==\"medium\":\n", + " for i in range(1,101):\n", + " numbers.append(i)\n", + " tries=7\n", + " print(\"Pick a number between 1 and 100. You have 7 turns. Let's play!\")\n", + "else:\n", + " for i in range(1,1001):\n", + " numbers.append(i)\n", + " tries=11\n", + " print(\"Pick a number between 1 and 1000. You have 11 turns. Let's play!\")" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import random\n", + "try_count=0\n", + "correct_value=random.choice(numbers)\n", + "\n", + "\n", + "print(correct_value)" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m while try_count Date: Thu, 25 Jun 2020 00:35:36 +0200 Subject: [PATCH 02/12] everything works fine --- your-project/All code.ipynb | 183 +++++++++++++++++++++++++++ your-project/Code.ipynb | 124 +++++++++++------- your-project/code good version.ipynb | 159 +++++++++++++++++++++++ 3 files changed, 421 insertions(+), 45 deletions(-) create mode 100644 your-project/All code.ipynb create mode 100644 your-project/code good version.ipynb diff --git a/your-project/All code.ipynb b/your-project/All code.ipynb new file mode 100644 index 0000000..111178b --- /dev/null +++ b/your-project/All code.ipynb @@ -0,0 +1,183 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pick your level: easy, medium or hard? easy\n", + "Great! You'll have to pick a number between 1 and 10. You have 5 turns to get it right. Let's play!\n", + "\n", + "Pick a number between 1 and 10: 2\n", + "You are too low, try again! Tries left: 4 \n", + "\n", + "Pick a number between 1 and 10: 6\n", + "Congratulations! You guessed the number!\n" + ] + } + ], + "source": [ + "#Ask for the level they want to play\n", + "levels=[\"easy\", \"medium\", \"hard\"]\n", + "def ask_level():\n", + " choice=input(\"Pick your level: easy, medium or hard? \").lower()\n", + " while choice not in levels:\n", + " print(\"Please, choose one of the options: easy, medium or hard\")\n", + " choice=input(\"\\nPick your level: easy, medium or hard? \").lower()\n", + " return choice\n", + "level=ask_level()\n", + "\n", + "#Set range of numbers and number of tries according to the level chosen\n", + "numbers=[]\n", + "if level==\"easy\":\n", + " for i in range(1,11):\n", + " numbers.append(i)\n", + " tries=5\n", + " print(\"Great! You'll have to pick a number between 1 and 10. You have 5 turns to get it right. Let's play!\\n\")\n", + "elif level==\"medium\":\n", + " for i in range(1,101):\n", + " numbers.append(i)\n", + " tries=7\n", + " print(\"Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\\n\")\n", + "else:\n", + " for i in range(1,1001):\n", + " numbers.append(i)\n", + " tries=10\n", + " print(\"Great! You'll have to pick a number between 1 and 1000. You have 10 turns to get it right. Let's play!\\n\")\n", + "\n", + "\n", + "#Generate random correct value\n", + "import random\n", + "correct_number=random.choice(numbers)\n", + "\n", + "\n", + "#Define function for user's guessed number\n", + "ask_number_text=\"Pick a number between \" + str(min(numbers)) + \" and \" + str(max(numbers)) + \": \"\n", + "str_numbers=[]\n", + "for i in range(0,len(numbers)):\n", + " str_numbers.append(str(i))\n", + " \n", + "def ask_number():\n", + " choice1=input(ask_number_text)\n", + " while choice1 not in str_numbers:\n", + " print(\"Please, pick a number within the range\\n\")\n", + " choice1=input(ask_number_text)\n", + " return int(choice1)\n", + "\n", + "#Run game\n", + "tries_count=0\n", + "for i in range(0, tries):\n", + " guess_number=ask_number()\n", + " if guess_number==correct_number:\n", + " print(\"Congratulations! You guessed the number!\")\n", + " break\n", + " elif guess_numbercorrect_number and tries_countcorrect_number and tries_count, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m while try_countcorrect_number and tries_countcorrect_number and tries_count Date: Thu, 25 Jun 2020 09:35:20 +0200 Subject: [PATCH 03/12] restarting kernel and clearing output --- your-project/code good version.ipynb | 53 ++-------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/your-project/code good version.ipynb b/your-project/code good version.ipynb index 52c07ce..bdda4f6 100644 --- a/your-project/code good version.ipynb +++ b/your-project/code good version.ipynb @@ -2,51 +2,9 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Pick your level: easy, medium or hard? medium\n", - "Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\n", - "\n", - "Pick a number between 1 and 100: 300\n", - "Please, pick a number within the range\n", - "\n", - "Pick a number between 1 and 100: 100\n", - "You are too high, try again! Tries left: 6 \n", - "\n", - "Pick a number between 1 and 100: 50\n", - "You are too high, try again! Tries left: 5 \n", - "\n", - "Pick a number between 1 and 100: 20\n", - "Congratulations! You guessed the number!\n", - "\n", - "Do you want to play another round? yes\n", - "\n", - "Pick your level: easy, medium or hard? easy\n", - "Great! You'll have to pick a number between 1 and 10. You have 4 turns to get it right. Let's play!\n", - "\n", - "Pick a number between 1 and 10: 4\n", - "You are too high, try again! Tries left: 3 \n", - "\n", - "Pick a number between 1 and 10: 1\n", - "You are too low, try again! Tries left: 2 \n", - "\n", - "Pick a number between 1 and 10: 2\n", - "You are too low, try again! Tries left: 1 \n", - "\n", - "Pick a number between 1 and 10: 3\n", - "Congratulations! You guessed the number!\n", - "\n", - "Do you want to play another round? no\n", - "Okay, thanks for playing the game. See you next time!\n" - ] - } - ], + "outputs": [], "source": [ "#Def ask_new_round() and set it to \"yes\" for first round:\n", "def ask_new_round():\n", @@ -126,13 +84,6 @@ "else:\n", " print(\"Okay, thanks for playing the game. See you next time!\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 1112326d1596607498021dcdedd741a25d290ca1 Mon Sep 17 00:00:00 2001 From: albabalcells Date: Thu, 25 Jun 2020 15:07:08 +0200 Subject: [PATCH 04/12] all good i think --- your-project/All code.ipynb | 183 ------------------------- your-project/CODI BO.ipynb | 235 +++++++++++++++++++++++++++++++++ your-project/Code.ipynb | 219 ------------------------------ your-project/Untitled.ipynb | 103 +++++++++++++++ your-project/Untitled2.ipynb | 61 +++++++++ your-project/code bobobo.ipynb | 130 ++++++++++++++++++ 6 files changed, 529 insertions(+), 402 deletions(-) delete mode 100644 your-project/All code.ipynb create mode 100644 your-project/CODI BO.ipynb delete mode 100644 your-project/Code.ipynb create mode 100644 your-project/Untitled.ipynb create mode 100644 your-project/Untitled2.ipynb create mode 100644 your-project/code bobobo.ipynb diff --git a/your-project/All code.ipynb b/your-project/All code.ipynb deleted file mode 100644 index 111178b..0000000 --- a/your-project/All code.ipynb +++ /dev/null @@ -1,183 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Pick your level: easy, medium or hard? easy\n", - "Great! You'll have to pick a number between 1 and 10. You have 5 turns to get it right. Let's play!\n", - "\n", - "Pick a number between 1 and 10: 2\n", - "You are too low, try again! Tries left: 4 \n", - "\n", - "Pick a number between 1 and 10: 6\n", - "Congratulations! You guessed the number!\n" - ] - } - ], - "source": [ - "#Ask for the level they want to play\n", - "levels=[\"easy\", \"medium\", \"hard\"]\n", - "def ask_level():\n", - " choice=input(\"Pick your level: easy, medium or hard? \").lower()\n", - " while choice not in levels:\n", - " print(\"Please, choose one of the options: easy, medium or hard\")\n", - " choice=input(\"\\nPick your level: easy, medium or hard? \").lower()\n", - " return choice\n", - "level=ask_level()\n", - "\n", - "#Set range of numbers and number of tries according to the level chosen\n", - "numbers=[]\n", - "if level==\"easy\":\n", - " for i in range(1,11):\n", - " numbers.append(i)\n", - " tries=5\n", - " print(\"Great! You'll have to pick a number between 1 and 10. You have 5 turns to get it right. Let's play!\\n\")\n", - "elif level==\"medium\":\n", - " for i in range(1,101):\n", - " numbers.append(i)\n", - " tries=7\n", - " print(\"Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\\n\")\n", - "else:\n", - " for i in range(1,1001):\n", - " numbers.append(i)\n", - " tries=10\n", - " print(\"Great! You'll have to pick a number between 1 and 1000. You have 10 turns to get it right. Let's play!\\n\")\n", - "\n", - "\n", - "#Generate random correct value\n", - "import random\n", - "correct_number=random.choice(numbers)\n", - "\n", - "\n", - "#Define function for user's guessed number\n", - "ask_number_text=\"Pick a number between \" + str(min(numbers)) + \" and \" + str(max(numbers)) + \": \"\n", - "str_numbers=[]\n", - "for i in range(0,len(numbers)):\n", - " str_numbers.append(str(i))\n", - " \n", - "def ask_number():\n", - " choice1=input(ask_number_text)\n", - " while choice1 not in str_numbers:\n", - " print(\"Please, pick a number within the range\\n\")\n", - " choice1=input(ask_number_text)\n", - " return int(choice1)\n", - "\n", - "#Run game\n", - "tries_count=0\n", - "for i in range(0, tries):\n", - " guess_number=ask_number()\n", - " if guess_number==correct_number:\n", - " print(\"Congratulations! You guessed the number!\")\n", - " break\n", - " elif guess_numbercorrect_number and tries_countcorrect_number and tries_countcorrect_number and tries_countcorrect_number and tries_countcorrect_number and tries_count Date: Thu, 25 Jun 2020 15:32:50 +0200 Subject: [PATCH 05/12] clearing output --- your-project/Untitled.ipynb | 103 -------------- your-project/Untitled2.ipynb | 61 -------- your-project/code bobobo.ipynb | 130 ------------------ ...CODI BO.ipynb => code final version.ipynb} | 69 +--------- your-project/code good version.ipynb | 110 --------------- 5 files changed, 6 insertions(+), 467 deletions(-) delete mode 100644 your-project/Untitled.ipynb delete mode 100644 your-project/Untitled2.ipynb delete mode 100644 your-project/code bobobo.ipynb rename your-project/{CODI BO.ipynb => code final version.ipynb} (76%) delete mode 100644 your-project/code good version.ipynb diff --git a/your-project/Untitled.ipynb b/your-project/Untitled.ipynb deleted file mode 100644 index 155f1f6..0000000 --- a/your-project/Untitled.ipynb +++ /dev/null @@ -1,103 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "range_num=range(-100,101)\n", - "range_str=[]\n", - "for i in range_num:\n", - " range_str.append(str(i))\n", - " \n", - "\n", - "range_tries_good=range(1,21)\n", - "range_tries_good_str=[]\n", - "for i in range_tries_good:\n", - " range_tries_good_str.append(str(i))\n", - "\n", - "range_tries_bad=range(21,100)\n", - "range_tries_bad_str=[]\n", - "for i in range_tries_bad:\n", - " range_tries_bad_str.append(str(i))\n", - " \n", - " \n", - "def custom_range_min():\n", - " choice=input(\"\\nChoose the minimum value of your range \")\n", - " while choice not in range_str:\n", - " choice=input(\"Please choose a number! \")\n", - " return int(choice)\n", - " return int(choice)\n", - "\n", - "def custom_range_max():\n", - " choice=input(\"\\nChoose the maximum value of your range \")\n", - " while choice not in range_str:\n", - " choice=input(\"Please, choose a number higher than {} \".format(range_min))\n", - " if choice in range_str:\n", - " while int(choice)<=range_min:\n", - " choice=input(\"Please, choose a number higher than {} \".format(range_min))\n", - " return int(choice)\n", - "\n", - "def custom_tries():\n", - " choice=input(\"\\nNow choose how many tries you want to have \")\n", - " while choice not in (range_tries_good_str or range_tries_bad_str):\n", - " choice=input(\"\\nPlease, choose a number between 1 and 100 \")\n", - " if choice in range_tries_bad_str:\n", - " answer=input(\"Wow, this a very high number of tries, are you sure you want to proceed? \").lower()\n", - " if answer==\"yes\":\n", - " return int(choice)\n", - " elif answer==\"no\":\n", - " choice=input(\"\\nOkay then, choose again a number between 1 and 100\")\n", - " while answer not in [\"yes\", \"no\"]:\n", - " answer=input(\"Please, say yes or no \")\n", - " if choice in range_tries_good_str:\n", - " return int(choice)\n", - " if choice in range_tries_bad_str:\n", - " answer=input(\"Wow, this a very high number of tries, are you sure you want to proceed? \").lower()\n", - " if answer==\"yes\":\n", - " return int(choice)\n", - " elif answer==\"no\":\n", - " choice=input(\"\\nPlease, choose a number between 1 and 100\")\n", - " while answer not in [\"yes\", \"no\"]:\n", - " answer=input(\"Please, say yes or no \")\n", - " elif choice in range_tries_good_str:\n", - " return int(choice)\n", - " \n", - "\n", - "custom_range_min\n", - "range_min=custom_range_min()\n", - "range_max=custom_range_max()\n", - "tries=custom_tries()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.2" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/your-project/Untitled2.ipynb b/your-project/Untitled2.ipynb deleted file mode 100644 index feb45f2..0000000 --- a/your-project/Untitled2.ipynb +++ /dev/null @@ -1,61 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "numbers=list(range(1,22))" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "numbers" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.2" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/your-project/code bobobo.ipynb b/your-project/code bobobo.ipynb deleted file mode 100644 index bec2c5c..0000000 --- a/your-project/code bobobo.ipynb +++ /dev/null @@ -1,130 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Pick your level: easy, medium or hard? easy\n", - "Great! You'll have to pick a number between 1 and 10. You have 4 turns to get it right. Let's play!\n", - "\n" - ] - } - ], - "source": [ - "#Def ask_new_round() and set it to \"yes\" for first round:\n", - "def ask_new_round():\n", - " choice=input(\"Do you want to play another round? \").lower()\n", - " while choice not in [\"yes\", \"no\"]:\n", - " choice=input(\"Please, say yes or no: \").lower()\n", - " return choice\n", - "new_round=\"yes\"\n", - "\n", - "#Start game\n", - "while new_round==\"yes\":\n", - " \n", - " #Ask for the level they want to play\n", - " levels=[\"easy\", \"medium\", \"hard\"]\n", - " def ask_level():\n", - " choice=input(\"\\nPick your level: easy, medium or hard? \").lower()\n", - " while choice not in levels:\n", - " print(\"\\nPlease, choose one of the options: easy, medium or hard\")\n", - " choice=input(\"\\nPick your level: easy, medium or hard? \").lower()\n", - " return choice\n", - " level=ask_level()\n", - "\n", - " #Set range of numbers and number of tries according to the level chosen\n", - " if level==\"easy\":\n", - " numbers=list(range(1,11))\n", - " tries=4\n", - " print(\"Great! You'll have to pick a number between 1 and 10. You have 4 turns to get it right. Let's play!\\n\")\n", - " elif level==\"medium\":\n", - " numbers=list(range(1,101))\n", - " tries=7\n", - " print(\"Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\\n\")\n", - " else:\n", - " numbers=list(range(1,1001))\n", - " tries=10\n", - " print(\"Great! You'll have to pick a number between 1 and 1000. You have 10 turns to get it right. Let's play!\\n\")\n", - "\n", - "\n", - " #Generate random correct value\n", - " import random\n", - " correct_number=random.choice(numbers)\n", - "\n", - "\n", - " #Define function for user's guessed number\n", - " \n", - " #Making a list of the number range chosen, each number stored as a string so that then it works when using input(), as the answer from the user will be stored as a string. We need this to make sure the input they put is in the range of numbers chosen.\n", - " str_numbers=[]\n", - " for i in numbers:\n", - " str_numbers.append(str(i))\n", - " \n", - " #Ask user for number and then turn it into a integer to compare it with the correct value\n", - " def ask_number():\n", - " choice1=input(\"Pick a number between {} and {}: \".format(str(min(numbers)), str(max(numbers))))\n", - " while choice1 not in str_numbers:\n", - " print(\"Please, pick a number within the range\\n\")\n", - " choice1=input(ask_number_text)\n", - " return int(choice1)\n", - "\n", - " #Run game\n", - " tries_count=0\n", - " for i in range(0, tries):\n", - " guess_number=ask_number()\n", - " if guess_number==correct_number:\n", - " print(\"Congratulations! You guessed the number!\\n\")\n", - " break\n", - " elif guess_numbercorrect_number and tries_countcorrect_number and tries_count Date: Thu, 25 Jun 2020 17:33:19 +0200 Subject: [PATCH 06/12] solving errors --- your-project/README.md | 34 ++- .../guess the number - explanations.ipynb | 196 ++++++++++++++++++ ...l version.ipynb => guess the number.ipynb} | 44 ++-- 3 files changed, 242 insertions(+), 32 deletions(-) create mode 100644 your-project/guess the number - explanations.ipynb rename your-project/{code final version.ipynb => guess the number.ipynb} (82%) diff --git a/your-project/README.md b/your-project/README.md index 2a8493d..eec438a 100644 --- a/your-project/README.md +++ b/your-project/README.md @@ -1,9 +1,9 @@ Ironhack Logo -# Title of Your Project -*[Your Name]* +# Guess the number +*_Alba Balcells_* -*[Your Cohort, Campus & Date]* +*_Data Analytics Barcelona, June 2020_* ## Content - [Project Description](#project-description) @@ -13,22 +13,34 @@ - [Links](#links) ## Project Description -Write a short description of your project. Write 1-2 sentences about the game you chose to build and why. +This code runs a "Guess the number" game, in which the user has to guess a number randomly generated by the computer. ## Rules -Briefly describe the rules of the game. -## Workflow -Outline the workflow you used in your project. What are the steps you went through? +The user can choose between one of the default levels of difficulty (easy, medium, hard) or set up their own rules. Each level corresponds to a range of possible numbers and a maximum number of tries. The computer will pick a random number and the user will have to guess it. For every wrong guess, the code will display whether the guess is below or above the correct number. The game finishes when the user guesses the number or when they run out of tries. + +## Workflow + - First, the code displays a welcome message with a brief introduction to the game. + - Then the user is asked to choose the level of difficulty (easy, medium, hard) or to set up their own rules ("let me choose" option). + - For each of the levels, the range of numbers and the maximum number of tries is set by default. For the "let me choose" option, the user is asked to input them instead. + - The computer randomly picks a number within the range specified. + - The user inputs their guess, and the code tells them whether they are correct or not. If they are not, the code informs whether their guess is above or below the correct number. + - The game will go on until the user inputs the correct guess or the maximum number of tries is reached. + - When one round is over, the user will choose whether to keep playing or to exit the game. + +__Note__: a warning message will be displayed when the user's input is not expected (e.g. text instead of number) + + ## Organization -How did you organize your work? Did you use any tools like a kanban board? +Used Trello to keep track of all the taskes. -What does your repository look like? Explain your folder and file structure. +Inside the repository there is a folder named _Guess the number_. The folder contains two Jupyter Notebook files, one with only the code and another with detailed explanations. ## Links Include links to your repository, slides and kanban board. Feel free to include any other links associated with your project. -[Repository](https://github.com/) +[Repository](https://github.com/albabalcells/Project-Week-1-Build-Your-Own-Game/) [Slides](https://slides.com/) -[Trello](https://trello.com/en) +[Trello](https://trello.com/b/QHmS0QUS/project-1-build-your-own-game/) + diff --git a/your-project/guess the number - explanations.ipynb b/your-project/guess the number - explanations.ipynb new file mode 100644 index 0000000..b2c3356 --- /dev/null +++ b/your-project/guess the number - explanations.ipynb @@ -0,0 +1,196 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Guess the number!\n", + "\n", + "This is a _Guess the number_ game. To play, you will have to choose between 3 levels of difficulty, or choose the rules yourself! The computer will generate a random number and you will have to guess it. \n", + "The code will tell you whether your guess is below or above the correct number, but be careful, you only have a limited number of tries!\n", + "\n", + "__Good luck!__" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Def ask_new_round() and set it to \"yes\" for first round:\n", + "def ask_new_round():\n", + " choice=input(\"Do you want to play another round? \").lower()\n", + " while choice not in [\"yes\", \"no\"]:\n", + " choice=input(\"Please, say yes or no: \").lower()\n", + " return choice\n", + "new_round=\"yes\"\n", + "\n", + "#Start game\n", + "while new_round==\"yes\":\n", + " \n", + " #Ask for the level they want to play\n", + " levels=[\"easy\", \"medium\", \"hard\", \"let me choose\"]\n", + " def ask_level():\n", + " choice=input(\"\\nPick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' \").lower()\n", + " while choice not in levels:\n", + " print(\"\\nPlease, choose one of the options\")\n", + " choice=input(\"\\nPick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' \").lower()\n", + " return choice\n", + " level=ask_level()\n", + "\n", + " #Set range of numbers and number of tries according to the level chosen\n", + " if level==\"easy\":\n", + " numbers=list(range(1,11))\n", + " tries=4\n", + " print(\"Great! You'll have to pick a number between 1 and 10. You have 4 turns to get it right. Let's play!\\n\")\n", + " elif level==\"medium\":\n", + " numbers=list(range(1,101))\n", + " tries=7\n", + " print(\"Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\\n\")\n", + " elif level==\"hard\":\n", + " numbers=list(range(1,1001))\n", + " tries=10\n", + " print(\"Great! You'll have to pick a number between 1 and 1000. You have 10 turns to get it right. Let's play!\\n\")\n", + " else:\n", + " #Define variables for \"let me choose\" option\n", + " print(\"\\nGreat! You'll have to choose the minimum and maximum numbers you want the game to have, and how many turns do you want to have to guess it. Let's play!\\n\")\n", + " \n", + " range_num=range(-100000,100001)\n", + " range_str=[]\n", + " for i in range_num:\n", + " range_str.append(str(i))\n", + "\n", + " range_tries_good=list(range(1,21))\n", + " range_tries_good_str=[]\n", + " for i in range_tries_good:\n", + " range_tries_good_str.append(str(i))\n", + "\n", + " range_tries_bad=list(range(21,101))\n", + " range_tries_bad_str=[]\n", + " for i in range_tries_bad:\n", + " range_tries_bad_str.append(str(i))\n", + " \n", + " total_tries_range=range_tries_good_str+range_tries_bad_str\n", + " \n", + " #Ask for minimum number in the range, function will only take numbers\n", + " def custom_range_min():\n", + " choice=input(\"\\nChoose the minimum value of your range: \")\n", + " while choice not in range_str:\n", + " choice=input(\"Please, choose a number: \")\n", + " return int(choice)\n", + "\n", + " #Ask for minimum number in the range, function will only take numbers higher than the minimum set up before\n", + " def custom_range_max():\n", + " choice=input(\"\\nChoose the maximum value of your range: \")\n", + " while choice not in range_str:\n", + " choice=input(\"Please, choose a number higher than {}: \".format(range_min))\n", + " while choice in range_str and int(choice)<=range_min:\n", + " if choice in range_str:\n", + " choice=input(\"Please, choose a number higher than {}: \".format(range_min))\n", + " while choice not in range_str:\n", + " choice=input(\"Please, choose a number higher than {}: \".format(range_min))\n", + " else:\n", + " return int(choice)\n", + "\n", + " #Ask for number of tries. Maximum available is 100. If tries>20, the code will display a warning message. \n", + " def custom_tries():\n", + " choice=input(\"\\nNow choose how many tries you want to have: \")\n", + " while choice not in total_tries_range:\n", + " choice=input(\"\\nPlease, choose a number between 1 and 100: \")\n", + " if choice in range_tries_bad_str:\n", + " answer=input(\"Wow, this a very high number of tries, are you sure you want to proceed? \").lower()\n", + " if answer==\"yes\":\n", + " return int(choice)\n", + " elif answer==\"no\":\n", + " choice=input(\"\\nOkay then, choose again a number between 1 and 100: \")\n", + " return int(choice)\n", + " while answer not in [\"yes\", \"no\"]:\n", + " answer=input(\"Please, say yes or no \")\n", + " if choice in range_tries_good_str:\n", + " return int(choice)\n", + " if choice in range_tries_bad_str:\n", + " answer=input(\"Wow, this a very high number of tries, are you sure you want to proceed? \").lower()\n", + " if answer==\"yes\":\n", + " return int(choice)\n", + " elif answer==\"no\":\n", + " choice=input(\"\\nPlease, choose a number between 1 and 100: \")\n", + " return int(choice)\n", + " while answer not in [\"yes\", \"no\"]:\n", + " answer=input(\"Please, say yes or no \")\n", + " elif choice in range_tries_good_str:\n", + " return int(choice)\n", + "\n", + " #Assign inputs from user to variables numbers and tries\n", + " custom_range_min\n", + " range_min=custom_range_min()\n", + " range_max=custom_range_max()\n", + " numbers=list(range(range_min,range_max+1))\n", + " tries=custom_tries()\n", + " \n", + " #Generate random correct number\n", + " import random\n", + " correct_number=random.choice(numbers)\n", + " \n", + " #Define function for user's guessed number\n", + "\n", + " #Making a list of the number range chosen, each number stored as a string so that then it works when using input(), as the answer from the user will be stored as a string. We need this to make sure the input they put is in the range of numbers chosen.\n", + " str_numbers=[]\n", + " for i in numbers:\n", + " str_numbers.append(str(i))\n", + " \n", + " #Ask user for number and then turn it into a integer to compare it with the correct value\n", + " def ask_number():\n", + " choice1=input(\"Pick a number between {} and {}: \".format(str(min(numbers)), str(max(numbers))))\n", + " while choice1 not in str_numbers:\n", + " choice1=input(\"Please, pick a number between {} and {}: \".format(str(min(numbers)), str(max(numbers))))\n", + " return int(choice1)\n", + "\n", + " #Run game\n", + " tries_count=0\n", + " for i in range(0, tries):\n", + " guess_number=ask_number()\n", + " if guess_number==correct_number:\n", + " print(\"Congratulations! You guessed the number!\\n\")\n", + " break\n", + " elif guess_numbercorrect_number and tries_count Date: Thu, 25 Jun 2020 17:37:42 +0200 Subject: [PATCH 07/12] Rename your-project/README.md to guess-the-number/README.md --- {your-project => guess-the-number}/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {your-project => guess-the-number}/README.md (100%) diff --git a/your-project/README.md b/guess-the-number/README.md similarity index 100% rename from your-project/README.md rename to guess-the-number/README.md From bd86778a1526f457e006d1c763c687b68278cc19 Mon Sep 17 00:00:00 2001 From: albabalcells <64869508+albabalcells@users.noreply.github.com> Date: Thu, 25 Jun 2020 17:38:30 +0200 Subject: [PATCH 08/12] Rename your-project/guess the number - explanations.ipynb to guess-the-number/code-explained.ipynb --- .../code-explained.ipynb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename your-project/guess the number - explanations.ipynb => guess-the-number/code-explained.ipynb (100%) diff --git a/your-project/guess the number - explanations.ipynb b/guess-the-number/code-explained.ipynb similarity index 100% rename from your-project/guess the number - explanations.ipynb rename to guess-the-number/code-explained.ipynb From ba00cbe08d6bdebd3635a9ff9abed9187c891789 Mon Sep 17 00:00:00 2001 From: albabalcells <64869508+albabalcells@users.noreply.github.com> Date: Thu, 25 Jun 2020 17:39:04 +0200 Subject: [PATCH 09/12] Rename your-project/guess the number.ipynb to guess-the-number/code.ipynb --- .../guess the number.ipynb => guess-the-number/code.ipynb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename your-project/guess the number.ipynb => guess-the-number/code.ipynb (100%) diff --git a/your-project/guess the number.ipynb b/guess-the-number/code.ipynb similarity index 100% rename from your-project/guess the number.ipynb rename to guess-the-number/code.ipynb From 91f902ba38acfbb03b623c36017fbdc8ac307a76 Mon Sep 17 00:00:00 2001 From: albabalcells Date: Thu, 25 Jun 2020 18:49:32 +0200 Subject: [PATCH 10/12] adding link to slides and running code --- your-project/README.md | 4 +- your-project/guess the number.ipynb | 71 ++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/your-project/README.md b/your-project/README.md index eec438a..f6a6051 100644 --- a/your-project/README.md +++ b/your-project/README.md @@ -41,6 +41,6 @@ Inside the repository there is a folder named _Guess the number_. The folder con Include links to your repository, slides and kanban board. Feel free to include any other links associated with your project. [Repository](https://github.com/albabalcells/Project-Week-1-Build-Your-Own-Game/) -[Slides](https://slides.com/) -[Trello](https://trello.com/b/QHmS0QUS/project-1-build-your-own-game/) +[Slides](https://drive.google.com/file/d/1n6W0RmnpQ2h1Cz5_a1qgrkOJJwbQbCGX/view?usp=sharing) +[Trello](https://trello.com/b/QHmS0QUS/project-1-build-your-own-game/) diff --git a/your-project/guess the number.ipynb b/your-project/guess the number.ipynb index a80e4fa..bada514 100644 --- a/your-project/guess the number.ipynb +++ b/your-project/guess the number.ipynb @@ -14,9 +14,69 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' easyy\n", + "\n", + "Please, choose one of the options\n", + "\n", + "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' Easy\n", + "Great! You'll have to pick a number between 1 and 10. You have 4 turns to get it right. Let's play!\n", + "\n", + "Pick a number between 1 and 10: 5\n", + "You are too low, try again! Tries left: 3 \n", + "\n", + "Pick a number between 1 and 10: 7\n", + "You are too low, try again! Tries left: 2 \n", + "\n", + "Pick a number between 1 and 10: 9\n", + "You are too low, try again! Tries left: 1 \n", + "\n", + "Pick a number between 1 and 10: 10\n", + "Congratulations! You guessed the number!\n", + "\n", + "Do you want to play another round? yes\n", + "\n", + "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' let me choose\n", + "\n", + "Great! You'll have to choose the minimum and maximum numbers you want the game to have, and how many turns do you want to have to guess it. Let's play!\n", + "\n", + "\n", + "Choose the minimum value of your range: 10\n", + "\n", + "Choose the maximum value of your range: 5\n", + "Please, choose a number higher than 10: 50\n", + "\n", + "Now choose how many tries you want to have: 30\n", + "Wow, this a very high number of tries, are you sure you want to proceed? no\n", + "\n", + "Please, choose a number between 1 and 100: 5\n", + "Pick a number between 10 and 50: 30\n", + "You are too high, try again! Tries left: 4 \n", + "\n", + "Pick a number between 10 and 50: 20\n", + "You are too high, try again! Tries left: 3 \n", + "\n", + "Pick a number between 10 and 50: 15\n", + "You are too high, try again! Tries left: 2 \n", + "\n", + "Pick a number between 10 and 50: 12\n", + "You are too high, try again! Tries left: 1 \n", + "\n", + "Pick a number between 10 and 50: 11\n", + "You don't have any tries left, you lose the game. The correct number was 10 \n", + "\n", + "Do you want to play another round? no\n", + "Okay, thanks for playing the game. See you next time!\n" + ] + } + ], "source": [ "def ask_new_round():\n", " choice=input(\"Do you want to play another round? \").lower()\n", @@ -154,6 +214,13 @@ "else:\n", " print(\"Okay, thanks for playing the game. See you next time!\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From a2ee7f7f25803ed67aa911c8611416542c67dd38 Mon Sep 17 00:00:00 2001 From: albabalcells Date: Fri, 26 Jun 2020 14:33:55 +0200 Subject: [PATCH 11/12] changing input that was wrong --- guess-the-number/code.ipynb | 58 ++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/guess-the-number/code.ipynb b/guess-the-number/code.ipynb index bada514..d755405 100644 --- a/guess-the-number/code.ipynb +++ b/guess-the-number/code.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -22,55 +22,65 @@ "output_type": "stream", "text": [ "\n", - "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' easyy\n", + "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' medium\n", + "Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\n", "\n", - "Please, choose one of the options\n", + "Pick a number between 1 and 100: 50\n", + "You are too high, try again! Tries left: 6 \n", + "\n", + "Pick a number between 1 and 100: 30\n", + "You are too high, try again! Tries left: 5 \n", "\n", - "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' Easy\n", - "Great! You'll have to pick a number between 1 and 10. You have 4 turns to get it right. Let's play!\n", + "Pick a number between 1 and 100: 10\n", + "You are too low, try again! Tries left: 4 \n", "\n", - "Pick a number between 1 and 10: 5\n", + "Pick a number between 1 and 100: 20\n", "You are too low, try again! Tries left: 3 \n", "\n", - "Pick a number between 1 and 10: 7\n", + "Pick a number between 1 and 100: 24\n", "You are too low, try again! Tries left: 2 \n", "\n", - "Pick a number between 1 and 10: 9\n", + "Pick a number between 1 and 100: 25\n", "You are too low, try again! Tries left: 1 \n", "\n", - "Pick a number between 1 and 10: 10\n", + "Pick a number between 1 and 100: 27\n", "Congratulations! You guessed the number!\n", "\n", "Do you want to play another round? yes\n", "\n", + "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' let me chooose\n", + "\n", + "Please, choose one of the options\n", + "\n", "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' let me choose\n", "\n", "Great! You'll have to choose the minimum and maximum numbers you want the game to have, and how many turns do you want to have to guess it. Let's play!\n", "\n", "\n", - "Choose the minimum value of your range: 10\n", + "Choose the minimum value of your range: 100\n", "\n", - "Choose the maximum value of your range: 5\n", - "Please, choose a number higher than 10: 50\n", + "Choose the maximum value of your range: 20\n", + "Please, choose a number higher than 100: 200\n", "\n", - "Now choose how many tries you want to have: 30\n", + "Now choose how many tries you want to have: 80\n", "Wow, this a very high number of tries, are you sure you want to proceed? no\n", "\n", - "Please, choose a number between 1 and 100: 5\n", - "Pick a number between 10 and 50: 30\n", - "You are too high, try again! Tries left: 4 \n", + "Okay then, choose again a number between 1 and 100: 5\n", + "Pick a number between 100 and 200: 150\n", + "You are too low, try again! Tries left: 4 \n", "\n", - "Pick a number between 10 and 50: 20\n", - "You are too high, try again! Tries left: 3 \n", + "Pick a number between 100 and 200: 250\n", + "Please, pick a number between 100 and 200: 130\n", + "You are too low, try again! Tries left: 3 \n", "\n", - "Pick a number between 10 and 50: 15\n", - "You are too high, try again! Tries left: 2 \n", + "Pick a number between 100 and 200: 170\n", + "You are too low, try again! Tries left: 2 \n", "\n", - "Pick a number between 10 and 50: 12\n", + "Pick a number between 100 and 200: 190\n", "You are too high, try again! Tries left: 1 \n", "\n", - "Pick a number between 10 and 50: 11\n", - "You don't have any tries left, you lose the game. The correct number was 10 \n", + "Pick a number between 100 and 200: 183\n", + "You don't have any tries left, you lose the game. The correct number was 175 \n", "\n", "Do you want to play another round? no\n", "Okay, thanks for playing the game. See you next time!\n" @@ -166,7 +176,7 @@ " if answer==\"yes\":\n", " return int(choice)\n", " elif answer==\"no\":\n", - " choice=input(\"\\nPlease, choose a number between 1 and 100: \")\n", + " choice=input(\"\\nOkay then, choose again a number between 1 and 100: \")\n", " return int(choice)\n", " while answer not in [\"yes\", \"no\"]:\n", " answer=input(\"Please, say yes or no \")\n", From 482db28bc50719ac1fb8ae46ed52893ec25af2ca Mon Sep 17 00:00:00 2001 From: albabalcells Date: Sun, 12 Jul 2020 13:03:16 +0200 Subject: [PATCH 12/12] deleting files from another project --- guess-the-number/Untitled.ipynb | 71 +++++++++++++++++++++++++++++++++ guess-the-number/code.ipynb | 69 +++++++++----------------------- 2 files changed, 90 insertions(+), 50 deletions(-) create mode 100644 guess-the-number/Untitled.ipynb diff --git a/guess-the-number/Untitled.ipynb b/guess-the-number/Untitled.ipynb new file mode 100644 index 0000000..eff6db0 --- /dev/null +++ b/guess-the-number/Untitled.ipynb @@ -0,0 +1,71 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "import random" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "correct=random.sample(range(10),1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Choose a number between 1 and 10: 1\n", + "Choose a number between 1 and 10: 2\n", + "Choose a number between 1 and 10: 3\n", + "Choose a number between 1 and 10: 4\n", + "Choose a number between 1 and 10: 5\n", + "Choose a number between 1 and 10: 6\n", + "Choose a number between 1 and 10: 7\n", + "Choose a number between 1 and 10: 8\n", + "Choose a number between 1 and 10: 9\n", + "Choose a number between 1 and 10: 10\n" + ] + } + ], + "source": [ + "number=int(input(\"Choose a number between 1 and 10: \"))\n", + "while number!=correct:\n", + " number==int(input(\"Choose a number between 1 and 10: \"))\n", + " if number==correct:\n", + " print(\"You win!\")\n", + "if number==correct:\n", + " print(\"You win!\")\n", + "number" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/guess-the-number/code.ipynb b/guess-the-number/code.ipynb index d755405..8f97225 100644 --- a/guess-the-number/code.ipynb +++ b/guess-the-number/code.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -25,65 +25,27 @@ "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' medium\n", "Great! You'll have to pick a number between 1 and 100. You have 7 turns to get it right. Let's play!\n", "\n", - "Pick a number between 1 and 100: 50\n", + "Pick a number between 1 and 100: 78\n", "You are too high, try again! Tries left: 6 \n", "\n", - "Pick a number between 1 and 100: 30\n", - "You are too high, try again! Tries left: 5 \n", + "Pick a number between 1 and 100: 34\n", + "You are too low, try again! Tries left: 5 \n", "\n", - "Pick a number between 1 and 100: 10\n", - "You are too low, try again! Tries left: 4 \n", + "Pick a number between 1 and 100: 56\n", + "You are too high, try again! Tries left: 4 \n", "\n", - "Pick a number between 1 and 100: 20\n", + "Pick a number between 1 and 100: 45\n", "You are too low, try again! Tries left: 3 \n", "\n", - "Pick a number between 1 and 100: 24\n", - "You are too low, try again! Tries left: 2 \n", + "Pick a number between 1 and 100: 50\n", + "You are too high, try again! Tries left: 2 \n", "\n", - "Pick a number between 1 and 100: 25\n", + "Pick a number between 1 and 100: 48\n", "You are too low, try again! Tries left: 1 \n", "\n", - "Pick a number between 1 and 100: 27\n", + "Pick a number between 1 and 100: 49\n", "Congratulations! You guessed the number!\n", - "\n", - "Do you want to play another round? yes\n", - "\n", - "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' let me chooose\n", - "\n", - "Please, choose one of the options\n", - "\n", - "Pick your level: easy, medium or hard? If you want to choose the rules yourself, please type 'let me choose' let me choose\n", - "\n", - "Great! You'll have to choose the minimum and maximum numbers you want the game to have, and how many turns do you want to have to guess it. Let's play!\n", - "\n", - "\n", - "Choose the minimum value of your range: 100\n", - "\n", - "Choose the maximum value of your range: 20\n", - "Please, choose a number higher than 100: 200\n", - "\n", - "Now choose how many tries you want to have: 80\n", - "Wow, this a very high number of tries, are you sure you want to proceed? no\n", - "\n", - "Okay then, choose again a number between 1 and 100: 5\n", - "Pick a number between 100 and 200: 150\n", - "You are too low, try again! Tries left: 4 \n", - "\n", - "Pick a number between 100 and 200: 250\n", - "Please, pick a number between 100 and 200: 130\n", - "You are too low, try again! Tries left: 3 \n", - "\n", - "Pick a number between 100 and 200: 170\n", - "You are too low, try again! Tries left: 2 \n", - "\n", - "Pick a number between 100 and 200: 190\n", - "You are too high, try again! Tries left: 1 \n", - "\n", - "Pick a number between 100 and 200: 183\n", - "You don't have any tries left, you lose the game. The correct number was 175 \n", - "\n", - "Do you want to play another round? no\n", - "Okay, thanks for playing the game. See you next time!\n" + "\n" ] } ], @@ -225,6 +187,13 @@ " print(\"Okay, thanks for playing the game. See you next time!\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null,