Skip to content

Commit

Permalink
1-7 előadások
Browse files Browse the repository at this point in the history
  • Loading branch information
Hatwagner F. Miklós committed Apr 9, 2022
1 parent ede2810 commit eca7a36
Show file tree
Hide file tree
Showing 7 changed files with 8,191 additions and 132 deletions.
256 changes: 172 additions & 84 deletions Prg_alapjai,_1_előadás.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -125,34 +125,6 @@
"\n"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "j_NhUbMswM81",
"outputId": "8917e548-3a6e-45a7-9bef-31f8f3d94e10"
},
"source": [
"2 + 3 + 4"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"9"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -162,42 +134,14 @@
"Itt még nincs jelentősége a szóközöknek, **tagolás**nak, de később még **nagyon fontos lesz**! Ld. még: [PEP 8](https://www.python.org/dev/peps/pep-0008/)"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "3JUb7in-xMGY",
"outputId": "3cd10589-5441-4713-94e0-e74c07fe8059"
},
"source": [
"2+3+4"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"9"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "QijUxXVQxPVe",
"outputId": "4183593b-f5b9-488d-aebd-e5ba6abcf864"
"outputId": "219971f5-bcf1-4456-a27f-857cd6834a03"
},
"source": [
"2 + 3+4"
Expand All @@ -211,10 +155,8 @@
"9"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
"metadata": {},
"execution_count": 2
}
]
},
Expand All @@ -225,7 +167,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "cWSRH7nUwnL6",
"outputId": "f43de53d-34a9-4ad4-ea73-04be7be3ba1a"
"outputId": "2c6889fb-97fb-48ae-812a-25f7baceb467"
},
"source": [
"-4 - 3"
Expand All @@ -239,10 +181,8 @@
"-7"
]
},
"metadata": {
"tags": []
},
"execution_count": 4
"metadata": {},
"execution_count": 3
}
]
},
Expand Down Expand Up @@ -281,7 +221,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "GTvtLHZEx9uo",
"outputId": "fb35c1fd-c073-4712-dda5-ba08150bbfff"
"outputId": "a8fc00c4-ae17-40d5-92c1-d6bb0b999e13"
},
"source": [
"5 / 3"
Expand All @@ -295,10 +235,8 @@
"1.6666666666666667"
]
},
"metadata": {
"tags": []
},
"execution_count": 10
"metadata": {},
"execution_count": 4
}
]
},
Expand Down Expand Up @@ -414,6 +352,93 @@
}
]
},
{
"cell_type": "markdown",
"source": [
"A számrendszer alapja nem csak 10-es lehet:"
],
"metadata": {
"id": "fzByp0mxUnki"
}
},
{
"cell_type": "code",
"source": [
"0b11 # bináris szám"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "JJz6wfpLUFvF",
"outputId": "b749de62-eb35-49b2-94b1-c12db4cea9e7"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"3"
]
},
"metadata": {},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"source": [
"0o11 # oktális szám"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "RV1w1OAzUbU3",
"outputId": "5223d344-d729-4d7c-f2b3-592133fb50bd"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"9"
]
},
"metadata": {},
"execution_count": 5
}
]
},
{
"cell_type": "code",
"source": [
"0x11 # hexadecimális szám"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "nPTTRYaqUgHb",
"outputId": "1e348c1f-fa6e-4ccd-ba47-b1980ff1e141"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"17"
]
},
"metadata": {},
"execution_count": 6
}
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -430,7 +455,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "u9Nk6W1dyoeK",
"outputId": "a48a2d39-5de5-42e4-8cb2-3732715f8d02"
"outputId": "9192d043-c2a1-44c0-9a73-4f6f879017f2"
},
"source": [
"type(42)"
Expand All @@ -444,10 +469,8 @@
"int"
]
},
"metadata": {
"tags": []
},
"execution_count": 15
"metadata": {},
"execution_count": 5
}
]
},
Expand Down Expand Up @@ -630,7 +653,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "lXdeZn892SOO",
"outputId": "efc7d8da-52d7-44bb-c89c-9d1d3a415676"
"outputId": "189cda84-e587-4683-9b85-52a0b5b71c23"
},
"source": [
"a = 3\n",
Expand All @@ -647,10 +670,8 @@
"12"
]
},
"metadata": {
"tags": []
},
"execution_count": 25
"metadata": {},
"execution_count": 4
}
]
},
Expand Down Expand Up @@ -796,7 +817,9 @@
"* megvalósítás: [IEEE-754](https://www.h-schmidt.net/FloatConverter/IEEE754.html) dupla pontosságú változata (double)\n",
"* 8 bájt, kb. 15-16 decimális jegy pontosság, ábrázolási határ: ±1.7 x 10<sup>-308</sup>-tól ±1.7 x 10<sup>+308</sup>-ig\n",
"* de számábrázolási hibák\n",
"* lassabb műveletvégzés, mint egészekkel"
"* lassabb műveletvégzés, mint egészekkel\n",
"\n",
"TODO: float('inf')"
]
},
{
Expand Down Expand Up @@ -869,7 +892,8 @@
"Automatikus típuskonverzió\n",
"* műveletvégzés csak azonos típusú adatokkal lehetséges\n",
"* az értelmező rögzített szabályok szerint automatikusan (implicit módon) konvertál\n",
"* ökölszabály: kisebbről nagyobbra, szűkebb ábrázolási képességű típusról a bővebbre, hogy ne vesszen el információ"
"* ökölszabály: kisebbről nagyobbra, szűkebb ábrázolási képességű típusról a bővebbre, hogy ne vesszen el információ\n",
"* implicit konverzió kevés esetben fordul elő, pl.: int → float, de egészet már nem alakít karakterlánccá vagy fordítva"
]
},
{
Expand Down Expand Up @@ -941,6 +965,70 @@
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 211
},
"id": "vvrYUBDWkUeu",
"outputId": "46011254-2506-4a24-d831-fe532f19d6aa"
},
"source": [
"a = 1\n",
"b = '2'\n",
"a + b"
],
"execution_count": null,
"outputs": [
{
"output_type": "error",
"ename": "TypeError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-783d199d7919>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'2'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0ma\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'"
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-e-BpPXtoP0V"
},
"source": [
"Fahrenheit fok konvertálása Celsius fokra"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "WshOXYoRnWva",
"outputId": "16483c1e-ec04-4d47-9030-ee7faa7c6b04"
},
"source": [
"f = 72\n",
"c = 5/9 * (f - 32)\n",
"print(c)"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"22.22222222222222\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -994,7 +1082,7 @@
"print(math.e) # Euler-konstans\n",
"print(math.inf) # A \"végtelen\" ábrázolható lebegőpontos típusban\n",
"print(-math.inf)\n",
"print(math.nan) # nem szám speciális érték"
"print(math.nan) # \"nem szám\" speciális érték"
],
"execution_count": null,
"outputs": [
Expand Down
Loading

0 comments on commit eca7a36

Please sign in to comment.