Compare commits
11 Commits
example
...
40c080ae51
Author | SHA1 | Date | |
---|---|---|---|
40c080ae51 | |||
402a92cf25 | |||
850a8adc84 | |||
8be959c68f | |||
0f936057dc | |||
a6d5edd004 | |||
744d3e8a99 | |||
23fe675c08 | |||
d63f25b4f7 | |||
d3d782b419 | |||
c0e4f76170 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,2 +1,5 @@
|
||||
.ipynb_checkpoints
|
||||
Pifile.lock
|
||||
Pipfile.lock.local/
|
||||
.jupyter
|
||||
.ipython
|
||||
.local
|
||||
|
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM python:slim
|
||||
|
||||
ENV TOKEN=''
|
||||
|
||||
WORKDIR /notebooks
|
||||
RUN useradd -d /notebooks python && chown -R python /notebooks && pip install jupyterlab
|
||||
|
||||
USER python
|
||||
CMD [ "jupyter", "lab", "--ip=0.0.0.0", "--NotebookApp.token=''", "--notebook-dir", "/notebooks", "picofumi.ipynb" ]
|
4
Pipfile
4
Pipfile
@@ -5,6 +5,7 @@ name = "pypi"
|
||||
|
||||
[packages]
|
||||
jupyterlab = "*"
|
||||
watchgod = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
@@ -12,4 +13,5 @@ jupyterlab = "*"
|
||||
python_version = "3.9"
|
||||
|
||||
[scripts]
|
||||
jupyter = "jupyter lab --notebook-dir notebooks notebooks/picofumi.ipynb"
|
||||
jupyter = "jupyter lab --notebook-dir notebooks notebooks/picofumi.ipynb"
|
||||
watch = "watchgod src.main.main"
|
||||
|
43
README.md
43
README.md
@@ -1,3 +1,44 @@
|
||||
# PicoFumi
|
||||
|
||||
A Python Tutorial app
|
||||
A Python Tutorial app
|
||||
|
||||
|
||||
## Installing Python
|
||||
You will need Python 3.9
|
||||
|
||||
## Window
|
||||
Either get it on the Microsoft Store or down load it [here](https://www.python.org/ftp/python/3.9.8/python-3.9.8-amd64.exe)
|
||||
|
||||
## Apt
|
||||
|
||||
```sudo apt install python3.9 python3-pip```
|
||||
|
||||
## Yum
|
||||
|
||||
```sudo yum install python3.9 python3-pip```
|
||||
|
||||
## Mac
|
||||
|
||||
Download it [here](https://www.python.org/ftp/python/3.9.8/python-3.9.8-macos11.pkg)
|
||||
|
||||
|
||||
|
||||
## Install pipenv
|
||||
|
||||
On Windows open Powershell
|
||||
On Linux or Mac open the terminal
|
||||
|
||||
```pip install pipenv```
|
||||
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```pipenv lock```
|
||||
|
||||
```pipenv sync```
|
||||
|
||||
|
||||
## Run Jupyter
|
||||
|
||||
```pipenv run jupyter```
|
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
image: picofumi
|
||||
ports:
|
||||
- 8888:8888
|
||||
volumes:
|
||||
- ./notebooks:/notebooks
|
||||
environment:
|
||||
- TOKEN=a
|
||||
restart: unless-stopped
|
@@ -7,11 +7,538 @@
|
||||
"source": [
|
||||
"# Pico Fumi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d8f95dd9-11ad-455d-854a-86a12d84fbda",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%run picofumi.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f97654b6-de87-4a5a-9dfb-e32eac6b62cd",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Printing"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0046af84-de64-4023-bdf5-335177caf22a",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(\"Pico Fumi\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ce8f228c-dbb3-4b49-87ea-2234d283f49d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Variables"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "781cbd75-5b16-4740-ac88-fda9672bcdbd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#string\n",
|
||||
"guess = \"123\"\n",
|
||||
"print(guess)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b41186fa-ff8a-4e5e-ba55-1c9450a5c9af",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#integer \n",
|
||||
"guesses = 0\n",
|
||||
"print(guesses)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4304923b-cbc9-48ca-9ee8-766487115c2f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Get User Input"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "3adeee26-8a18-4bad-946b-3d06920ef82f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdin",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter a three digit number: 1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"guess = input(\"Enter a three digit number:\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "ec055f06-6fdd-4ab9-bce2-d56c82093c4b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(guess)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8999ef19-6a3c-41ea-bf2b-11dcbbe64070",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check that the guess a 3 digit number"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"id": "f7bcf18f-4e98-453f-bc1f-ef61b0aa55e4",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(guess)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"id": "53fca278-f55e-43f1-ab5f-f6df4fb7c163",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"False"
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(guess) == 3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"id": "bd9b231e-53c5-4b05-8f55-86ccf289b1e1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Guess is not 3 digits\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"if len(guess) != 3:\n",
|
||||
" print(\"Guess is not 3 digits\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2f806636-3296-42ce-914f-356e34e066a7",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Re-prompt the user until they enter a 3 digit number"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"id": "d427210a-75be-4a47-83e2-fbdffa2b2644",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdin",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter a three digit number: 123\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"guess = input(\"Enter a three digit number:\")\n",
|
||||
"while len(guess) != 3:\n",
|
||||
" guess = input(\"Enter a three digit number:\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6e3fa703-3f5f-4622-b8f5-349f61371282",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Break guess into 3 parts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 56,
|
||||
"id": "7e1a2228-3316-4652-9051-70c355de94bb",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"['1', '2', '3']\n",
|
||||
"1\n",
|
||||
"3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"guess = list(guess)\n",
|
||||
"print(guess)\n",
|
||||
"print(guess[0])\n",
|
||||
"print(guess[2])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ccd7b9d1-c266-498e-9f46-63c522c4d332",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Itterate over the guess"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 57,
|
||||
"id": "ddca84c9-2fff-4302-afd0-7096649bcdc7",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1\n",
|
||||
"2\n",
|
||||
"3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for part in guess:\n",
|
||||
" print(part)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 58,
|
||||
"id": "f631cc60-92e9-4c16-a5ab-4f50dfd10cc2",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"index 0 value 1\n",
|
||||
"index 1 value 2\n",
|
||||
"index 2 value 3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for index, value in enumerate(guess):\n",
|
||||
" print(f'index {index} value {value}')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "201cae7a-2cc5-4ff0-ac16-730091e24b72",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Functions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"id": "3aebea62-fa40-4e87-8229-3aafb051a006",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def GetGuess():\n",
|
||||
" guess = input(\"Enter a three digit number:\")\n",
|
||||
" while len(guess) != 3:\n",
|
||||
" guess = input(\"Enter a three digit number:\")\n",
|
||||
" return list(guess)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"id": "a2430233-5753-433d-bada-d8ee086f2bb2",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdin",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter a three digit number: 12\n",
|
||||
"Enter a three digit number: 12\n",
|
||||
"Enter a three digit number: 34\n",
|
||||
"Enter a three digit number: 123\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['1', '2', '3']"
|
||||
]
|
||||
},
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"GetGuess()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "77ab1ca2-0ea0-43b3-b6bd-d4438fa8141d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Random Numbers"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"id": "f4412eef-6b79-4329-b8e7-85f916d3dfbf",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import random \n",
|
||||
"random.seed()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"id": "c9324728-63c2-4023-92fc-3e1e80dff03a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"536\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"number = random.randrange(100,999)\n",
|
||||
"print(number)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 47,
|
||||
"id": "183e5444-2b79-4366-84cf-4da91c2547cf",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"int"
|
||||
]
|
||||
},
|
||||
"execution_count": 47,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"type(number)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 48,
|
||||
"id": "afe9d668-aefd-4021-9028-a21b04e931cd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"number = str(number)\n",
|
||||
"number = list(number)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a5f6f56b-0678-4f82-9539-ae7c798d6c63",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check if number guessed is correct"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 51,
|
||||
"id": "6194de2b-2dbe-4c49-bc00-e5bed3c35f1f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdin",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter a three digit number: \n",
|
||||
"Enter a three digit number: 123\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"You guessed wrong\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"guess = GetGuess()\n",
|
||||
"if guess == number:\n",
|
||||
" print(\"You guessed correctly\")\n",
|
||||
"else:\n",
|
||||
" print(\"You guessed wrong\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0496040d-4d2c-4580-9993-d1832568cd6b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check Fumi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 55,
|
||||
"id": "ab9145db-4662-41ae-ba38-6c66c7402d80",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"index 0 value 1\n",
|
||||
"index 1 value 2\n",
|
||||
"index 2 value 3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for index, value in enumerate(guess):\n",
|
||||
" print(f'index {index} value {value}')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f647c557-d247-48b9-8c31-5623dea46336",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load picofumi.py\n",
|
||||
"import random \n",
|
||||
"random.seed()\n",
|
||||
"\n",
|
||||
"number = random.randrange(100, 999)\n",
|
||||
"number = list(str(number))\n",
|
||||
"guesses = 0\n",
|
||||
"while True:\n",
|
||||
" \n",
|
||||
" if guesses == 5:\n",
|
||||
" print(\"You loose!\")\n",
|
||||
" for value in number:\n",
|
||||
" print(value, end=\" \")\n",
|
||||
" break\n",
|
||||
" hint = [\" \", \" \", \" \"]\n",
|
||||
" guess = input(\"Enter a three digit number:\")\n",
|
||||
" while len(guess) != 3:\n",
|
||||
" guess = input(\"Enter a three digit number:\")\n",
|
||||
" \n",
|
||||
" guess = list(guess)\n",
|
||||
" if guess == number:\n",
|
||||
" print(\"You win!\")\n",
|
||||
" break\n",
|
||||
" for index, value in enumerate(guess):\n",
|
||||
" print(value, end=\" \")\n",
|
||||
" if value in number:\n",
|
||||
" hint[index] = \"P\"\n",
|
||||
" print(\"\")\n",
|
||||
" for index, value in enumerate(guess):\n",
|
||||
" if number[index] == value:\n",
|
||||
" hint[index] = \"F\"\n",
|
||||
" print(hint[index], end=\" \")\n",
|
||||
" guesses += 1\n",
|
||||
" print(\"\\n\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1abd05b8-dfca-4fcc-8bb0-57dd77329086",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ls\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -25,7 +552,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.7"
|
||||
"version": "3.10.1"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
33
notebooks/picofumi.py
Normal file
33
notebooks/picofumi.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import random
|
||||
random.seed()
|
||||
|
||||
number = random.randrange(100, 999)
|
||||
number = list(str(number))
|
||||
guesses = 0
|
||||
while True:
|
||||
|
||||
if guesses == 5:
|
||||
print("You loose!")
|
||||
for value in number:
|
||||
print(value, end=" ")
|
||||
break
|
||||
hint = [" ", " ", " "]
|
||||
guess = input("Enter a three digit number:")
|
||||
while len(guess) != 3:
|
||||
guess = input("Enter a three digit number:")
|
||||
|
||||
guess = list(guess)
|
||||
if guess == number:
|
||||
print("You win!")
|
||||
break
|
||||
for index, value in enumerate(guess):
|
||||
print(value, end=" ")
|
||||
if value in number:
|
||||
hint[index] = "P"
|
||||
print("")
|
||||
for index, value in enumerate(guess):
|
||||
if number[index] == value:
|
||||
hint[index] = "F"
|
||||
print(hint[index], end=" ")
|
||||
guesses += 1
|
||||
print("\n")
|
5
src/main.py
Normal file
5
src/main.py
Normal file
@@ -0,0 +1,5 @@
|
||||
def main():
|
||||
print("Hello World")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user