PicoFumi/notebooks/picofumi.ipynb

530 lines
9.3 KiB
Plaintext
Raw Normal View History

2021-11-08 07:51:24 +00:00
{
"cells": [
{
"cell_type": "markdown",
"id": "e1d4d9e8-1781-4d55-9a57-d7c505009a04",
"metadata": {},
"source": [
"# Pico Fumi"
]
2021-12-08 07:54:31 +00:00
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 25,
"id": "d8f95dd9-11ad-455d-854a-86a12d84fbda",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 123\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 2 3 \n",
" \n",
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 456\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"4 5 6 \n",
" P \n",
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 789\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"7 8 9 \n",
" F \n",
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 588\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"5 8 8 \n",
"F F P \n",
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 585\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"5 8 5 \n",
"F F P \n",
"\n",
"You loose!\n",
"5 8 0 "
]
}
],
"source": [
"%run picofumi.py"
]
},
{
"cell_type": "markdown",
"id": "f97654b6-de87-4a5a-9dfb-e32eac6b62cd",
"metadata": {},
"source": [
"## Printing"
]
},
{
"cell_type": "code",
"execution_count": 10,
2021-12-08 07:54:31 +00:00
"id": "0046af84-de64-4023-bdf5-335177caf22a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Pico Fumi\n"
]
}
],
"source": [
"print(\"Pico Fumi\")"
]
},
2021-12-11 05:19:48 +00:00
{
"cell_type": "markdown",
"id": "ce8f228c-dbb3-4b49-87ea-2234d283f49d",
"metadata": {},
"source": [
"## Variables"
]
},
2021-12-08 07:54:31 +00:00
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 13,
"id": "781cbd75-5b16-4740-ac88-fda9672bcdbd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"123\n"
]
}
],
"source": [
"guess = \"123\"\n",
"print(guess)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "b41186fa-ff8a-4e5e-ba55-1c9450a5c9af",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n"
]
}
],
"source": [
"guesses = 0\n",
"print(guesses)"
]
},
{
"cell_type": "markdown",
"id": "4304923b-cbc9-48ca-9ee8-766487115c2f",
"metadata": {},
"source": [
"## Get User Input"
]
},
{
"cell_type": "code",
"execution_count": 6,
2021-12-08 07:54:31 +00:00
"id": "3adeee26-8a18-4bad-946b-3d06920ef82f",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"Enter a three digit number: 123\n"
2021-12-08 07:54:31 +00:00
]
}
],
"source": [
"guess = input(\"Enter a three digit number:\")"
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 16,
"id": "ec055f06-6fdd-4ab9-bce2-d56c82093c4b",
2021-12-08 07:54:31 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"123\n"
2021-12-08 07:54:31 +00:00
]
}
],
"source": [
2021-12-11 05:19:48 +00:00
"print(guess)"
]
},
{
"cell_type": "markdown",
"id": "6e3fa703-3f5f-4622-b8f5-349f61371282",
"metadata": {},
"source": [
"## Break guess into 3 parts"
2021-12-08 07:54:31 +00:00
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 17,
"id": "7e1a2228-3316-4652-9051-70c355de94bb",
2021-12-08 07:54:31 +00:00
"metadata": {},
2021-12-11 05:19:48 +00:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['1', '2', '3']\n"
]
}
],
2021-12-08 07:54:31 +00:00
"source": [
2021-12-11 05:19:48 +00:00
"guess = list(guess)\n",
"print(guess)"
]
},
{
"cell_type": "markdown",
"id": "ccd7b9d1-c266-498e-9f46-63c522c4d332",
"metadata": {},
"source": [
"## Itterate over the parts"
2021-12-08 07:54:31 +00:00
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 26,
"id": "ddca84c9-2fff-4302-afd0-7096649bcdc7",
2021-12-08 07:54:31 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"5\n",
"8\n",
"5\n"
2021-12-08 07:54:31 +00:00
]
}
],
"source": [
2021-12-11 05:19:48 +00:00
"for part in guess:\n",
" print(part)"
]
},
{
"cell_type": "markdown",
"id": "77ab1ca2-0ea0-43b3-b6bd-d4438fa8141d",
"metadata": {},
"source": [
"## Random Numbers"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "f4412eef-6b79-4329-b8e7-85f916d3dfbf",
"metadata": {},
"outputs": [],
"source": [
"import random \n",
"random.seed()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c9324728-63c2-4023-92fc-3e1e80dff03a",
"metadata": {},
"outputs": [],
"source": [
"number = random.randrange(100,999)\n",
2021-12-08 07:54:31 +00:00
"print(number)"
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 6,
2021-12-08 07:54:31 +00:00
"id": "6194de2b-2dbe-4c49-bc00-e5bed3c35f1f",
"metadata": {},
"outputs": [],
"source": [
"finished = False"
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 7,
2021-12-08 07:54:31 +00:00
"id": "e6e0b1c2-7c4b-4538-8421-bfdd027b1857",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"Enter a three digit number: 123\n",
"Enter a three digit number: 123\n",
"Enter a three digit number: 345\n",
"Enter a three digit number: 23\n",
"Enter a three digit number: 100\n",
"Enter a three digit number: 675\n"
2021-12-08 07:54:31 +00:00
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"You win\n"
]
}
],
"source": [
"while finished == False:\n",
" guess = input(\"Enter a three digit number:\")\n",
" # covert to integer\n",
2021-12-11 05:19:48 +00:00
" guess = int(guess)675\n",
2021-12-08 07:54:31 +00:00
" if guess == number:\n",
" print(\"You win\")\n",
" finished = True"
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 8,
2021-12-08 07:54:31 +00:00
"id": "232eb403-b705-447e-8d16-0909c4e63e6a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"707\n"
2021-12-08 07:54:31 +00:00
]
}
],
2021-12-11 05:19:48 +00:00
"source": []
2021-12-08 07:54:31 +00:00
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 9,
2021-12-08 07:54:31 +00:00
"id": "12d5c294-7fc8-47ad-a3bd-45d10bbed198",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"['7', '0', '7']\n"
2021-12-08 07:54:31 +00:00
]
}
],
"source": [
"number_parts = [s for s in str(number)]\n",
"print(number_parts)"
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 24,
2021-12-08 07:54:31 +00:00
"id": "a4d0cfc2-34a1-43e8-8c91-5fe2918a4e9e",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 123\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 2 3 \n",
2021-12-11 05:19:48 +00:00
"P \n",
2021-12-08 07:54:31 +00:00
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 456\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"4 5 6 \n",
2021-12-11 05:19:48 +00:00
" \n",
2021-12-08 07:54:31 +00:00
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
2021-12-11 05:19:48 +00:00
"Enter a three digit number: 789\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"7 8 9 \n",
"P P \n",
"\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter a three digit number: 817\n"
2021-12-08 07:54:31 +00:00
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"You win!\n"
]
}
],
2021-12-11 05:19:48 +00:00
"source": []
},
{
"cell_type": "code",
"execution_count": 22,
"id": "c43c7dc8-93f2-4f61-821f-1f8f0c2aba39",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9\r"
]
}
],
2021-12-08 07:54:31 +00:00
"source": [
2021-12-11 05:19:48 +00:00
"from time import sleep\n",
"for i in range(10):\n",
" print(i, end=\"\\r\")\n",
" sleep(1)"
2021-12-08 07:54:31 +00:00
]
},
{
"cell_type": "code",
2021-12-11 05:19:48 +00:00
"execution_count": 22,
2021-12-08 07:54:31 +00:00
"id": "f647c557-d247-48b9-8c31-5623dea46336",
"metadata": {},
2021-12-11 05:19:48 +00:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"IPython will make a temporary file named: /tmp/ipython_edit_m0vz1ei2/ipython_edit_oww2f6iw.py\n"
]
}
],
"source": [
"%edit"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1abd05b8-dfca-4fcc-8bb0-57dd77329086",
"metadata": {},
2021-12-08 07:54:31 +00:00
"outputs": [],
2021-12-11 05:19:48 +00:00
"source": [
"ls\n"
]
2021-11-08 07:51:24 +00:00
}
],
"metadata": {
"kernelspec": {
2021-12-11 05:19:48 +00:00
"display_name": "Python 3 (ipykernel)",
2021-11-08 07:51:24 +00:00
"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",
2021-12-11 05:19:48 +00:00
"version": "3.10.1"
2021-11-08 07:51:24 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}