Überarbeitung des Codes (Optimierung) und kleine Features Hinzugefügt (Multiplikator + Counter)
212 lines
3.9 KiB
Plaintext
212 lines
3.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c74a7a8e-6e0a-4f42-a18f-46b1aa7fddb1",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Kopf (1x)\n",
|
|
"\n",
|
|
"Du hast 5.5 Coins (+ 0.5)\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Kopf (1x)\n",
|
|
"\n",
|
|
"Du hast 6.0 Coins (+ 0.5)\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Kopf (2x)\n",
|
|
"\n",
|
|
"Du hast 7.0 Coins (+ 1.0)\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdin",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" \n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Zahl\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#import menu\n",
|
|
"import random\n",
|
|
"\n",
|
|
"propability = 40\n",
|
|
"coins_per_head = 0.5\n",
|
|
"coins = 5\n",
|
|
"coins_amount = 1\n",
|
|
"\n",
|
|
"def coin_flip(propability, coins, coins_per_head, coins_amount):\n",
|
|
" while True:\n",
|
|
" result = random.randint(0, 100)\n",
|
|
" if result in range(0,propability):\n",
|
|
" print(f'Kopf ({coins_amount}x)') \n",
|
|
" coins_amount += 1 #Anzahl an hintereinander geworfenen \"Köpfen\"\n",
|
|
" if coins_amount >=3:\n",
|
|
" coins_per_head += 0.5 #Coin-Boost für mehrfaches werfen von Kopf hintereinander\n",
|
|
" else:\n",
|
|
" coins_per_head = 0.5\n",
|
|
" coins += coins_per_head\n",
|
|
" print('')\n",
|
|
" print(f'Du hast {coins} Coins (+ {coins_per_head})')\n",
|
|
" input()\n",
|
|
" elif result in range(propability,100):\n",
|
|
" print('Zahl')\n",
|
|
" coins_amount = 1\n",
|
|
" input()\n",
|
|
"\n",
|
|
"\n",
|
|
"coin_flip(propability, coins, coins_per_head, coins_amount)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e0acbe2a-a8d1-4928-8e49-dd39a75d2b83",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"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.12.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|