Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
48 changes: 48 additions & 0 deletions .gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

# Created by https://www.toptal.com/developers/gitignore/api/jupyternotebooks,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=jupyternotebooks,macos

### 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

# End of https://www.toptal.com/developers/gitignore/api/jupyternotebooks,macos
Binary file added your-project/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pseudocode\n",
"- Define random number with function\n",
"import random -> random.randint(1,20) -> safe random nr in variable\n",
"\n",
"- explain player rules: player needs to guess a integer nr, from a random generated range between 1 - 20. limit 5 guesses.\n",
"text with rules + input option for player. \n",
"input needs to be integer -> write it for player and in input\n",
"\n",
"- new player input for guessing up to 5 times. -> while loop with limit of 5\n",
"(- if wrong --> too high or too low)\n",
"- After 5 wrong ones --> stop\n",
"- if guessed --> great, player won!!! --> Stop"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def guess_the_game():\n",
"\n",
" import random\n",
" x = random.randint(0, 20)\n",
" # print(x)\n",
"\n",
" count = 0\n",
" guess_lim = 5\n",
" guesses_left = 5\n",
"\n",
" print(\"Hi, you will have 5 guesses. Please choose a number between 0 and 20\\n\")\n",
"\n",
"\n",
" while count < guess_lim:\n",
" try:\n",
" guess = int(input(\"Can you guess the Secret Number?! Please type your guess as an integer: \"))\n",
" \n",
" if guess > 20 or guess < 0 :\n",
" print(\"Sorry, the number you guesses is without the requested range\\n\")\n",
" count = count + 1 \n",
" guesses_left = guesses_left - 1\n",
" print(\"You have\", (guesses_left), \"left\\n\")\n",
" \n",
" elif guess == x:\n",
" print(\"Woohooo!!! You won!! That's the correct number\\n\")\n",
" break\n",
" \n",
" elif guess > x:\n",
" print(\"Sorry, the number you guessed to too high\\n\")\n",
" count = count + 1 \n",
" guesses_left = guesses_left - 1\n",
" print(\"You have\", (guesses_left), \"left\\n\")\n",
" \n",
" else:\n",
" print(\"Sorry, the number you guessed is too low\\n\")\n",
" count = count + 1 \n",
" guesses_left = guesses_left - 1\n",
" print(\"You have\", (guesses_left), \"left\\n\")\n",
" \n",
" except ValueError:\n",
" print(\"Please enter an integer\")\n",
"\n",
" else:\n",
" print(\"Sorry, you lost, you reached 5 guesses... Thank's for playing\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"guess_the_game()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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.5"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}
154 changes: 154 additions & 0 deletions your-project/Code Game "Guess the number".ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pseudocode\n",
"- Define random number with function\n",
"import random -> random.randint(1,20) -> safe random nr in variable\n",
"\n",
"- explain player rules: player needs to guess a integer nr, from a random generated range between 1 - 20. limit 5 guesses.\n",
"text with rules + input option for player. \n",
"input needs to be integer -> write it for player and in input\n",
"\n",
"- new player input for guessing up to 5 times. -> while loop with limit of 5\n",
"(- if wrong --> too high or too low)\n",
"- After 5 wrong ones --> stop\n",
"- if guessed --> great, player won!!! --> Stop"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def guess_the_game():\n",
"\n",
" import random\n",
" x = random.randint(0, 20)\n",
" # print(x)\n",
"\n",
" count = 0\n",
" guess_lim = 5\n",
" guesses_left = 5\n",
"\n",
" print(\"Hi, you will have 5 guesses. Please choose a number between 0 and 20\\n\")\n",
"\n",
"\n",
" while count < guess_lim:\n",
" try:\n",
" guess = int(input(\"Can you guess the Secret Number?! Please type your guess as an integer: \"))\n",
" \n",
" if guess > 20 or guess < 0 :\n",
" print(\"Sorry, the number you guesses is without the requested range\\n\")\n",
" count = count + 1 \n",
" guesses_left = guesses_left - 1\n",
" print(\"You have\", (guesses_left), \"left\\n\")\n",
" \n",
" elif guess == x:\n",
" print(\"Woohooo!!! You won!! That's the correct number\\n\")\n",
" break\n",
" \n",
" elif guess > x:\n",
" print(\"Sorry, the number you guessed to too high\\n\")\n",
" count = count + 1 \n",
" guesses_left = guesses_left - 1\n",
" print(\"You have\", (guesses_left), \"left\\n\")\n",
" \n",
" else:\n",
" print(\"Sorry, the number you guessed is too low\\n\")\n",
" count = count + 1 \n",
" guesses_left = guesses_left - 1\n",
" print(\"You have\", (guesses_left), \"left\\n\")\n",
" \n",
" except ValueError:\n",
" print(\"Please enter an integer\")\n",
"\n",
" else:\n",
" print(\"Sorry, you lost, you reached 5 guesses... Thank's for playing\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"guess_the_game()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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.5"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading