PracticeForExam

This commit is contained in:
2024-12-05 23:20:53 +01:00
parent bcff76d934
commit a1e0e21582
5 changed files with 240 additions and 34 deletions

View File

@ -48,15 +48,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"42\n",
"58\n"
"53\n",
"47\n"
]
}
],
@ -78,10 +78,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"54\n",
"46\n"
]
}
],
"source": [
"x = [random.choice([\"fej\", \"írás\"]) for i in range(100)]\n",
"\n",
"print(x.count(\"fej\"))\n",
"print(x.count(\"írás\"))"
]
},
{
"cell_type": "markdown",
@ -132,7 +146,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
@ -175,10 +189,46 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['H', 'H', 'H', 'T', 'T', 'T', 'H', 'T', 'H', 'H']\n",
"3\n",
"2\n"
]
}
],
"source": [
"# ... a leghosszabb sorozat hossza (nem külön-külön számolva)\n",
"\n",
"import random\n",
"n = 10\n",
"sorsolas = [random.choice('HT') for i in range(n)]\n",
"\n",
"sorozat = 1\n",
"sorozat_max = 1\n",
"db = 0\n",
"for x in range(1, n):\n",
" if sorsolas[x] == sorsolas[x - 1]:\n",
" sorozat += 1\n",
" else:\n",
" sorozat = 1\n",
" \n",
" if sorozat > sorozat_max:\n",
" sorozat_max = sorozat\n",
" db = 0\n",
"\n",
" if sorozat == sorozat_max:\n",
" db+= 1\n",
" \n",
"print(sorsolas)\n",
"print(sorozat_max)\n",
"print(db)"
]
},
{
"cell_type": "markdown",
@ -210,10 +260,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7924\n"
]
}
],
"source": [
"import datetime\n",
"import random\n",
"\n",
"\n",
"born = datetime.date(2003,3,27)\n",
"today = datetime.date.today()\n",
"dif = today - born\n",
"\n",
"print(dif.days)\n",
"\n",
"rnum = datetime.date(2024, random.randint(1,12), random.randint(1,27))\n",
"\n"
]
},
{
"cell_type": "markdown",
@ -227,7 +298,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -241,7 +312,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.12.3"
}
},
"nbformat": 4,