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
109 changes: 109 additions & 0 deletions your-code/.ipynb_checkpoints/Dice_game-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import random\n",
"import time\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"You found a dice! If you roll the dice and get an even number you get the masterkey to escape from the scary house.\n",
"Are you ready?\n",
"00:00\n",
"You rolled number 5 you didn't escape by rolling the dice -_-'\n"
]
},
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Describes setting and initiate g# your code\n",
"def countdown(t=10):\n",
" while t != 0:\n",
" mins, secs = divmod(t, 60)\n",
" timeformat = \"{:02d}:{:02d}\".format(mins, secs)\n",
" print(timeformat, end=\"\\r\")\n",
" time.sleep(1)\n",
" t -= 1\n",
" timeformat = \"{:02d}:{:02d}\".format(0,0)\n",
" print(timeformat)\n",
"\n",
"\n",
"### dice game!\n",
"def dice_game():\n",
" \"\"\"\n",
" Roll the dice\n",
" \"\"\"\n",
" print(\"You found a dice! If you roll the dice and get an even number you get the masterkey to escape from the scary house.\")\n",
" print(\"Are you ready?\")\n",
" time.sleep(1)\n",
" countdown(3)\n",
" rolled_num = random.randint(1,18)\n",
" if rolled_num % 2 == 0:\n",
" print(\"Congratulations, you rolled \", rolled_num, \" and thus you the master key!\")\n",
" return True \n",
" else:\n",
" print(\"You rolled number\", rolled_num,\"you didn't escape by rolling the dice -_-'\")\n",
" return False\n",
" \n",
" \n",
"dice_game()"
]
},
{
"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.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading