Skip to content

Commit d297cfe

Browse files
Functions
1 parent 2f8e693 commit d297cfe

File tree

1 file changed

+99
-2
lines changed

1 file changed

+99
-2
lines changed

PythonFromScratch.ipynb

+99-2
Original file line numberDiff line numberDiff line change
@@ -2237,12 +2237,109 @@
22372237
"print(tp)"
22382238
]
22392239
},
2240+
{
2241+
"cell_type": "markdown",
2242+
"metadata": {},
2243+
"source": [
2244+
"# Functions"
2245+
]
2246+
},
22402247
{
22412248
"cell_type": "code",
2242-
"execution_count": null,
2249+
"execution_count": 18,
2250+
"metadata": {},
2251+
"outputs": [
2252+
{
2253+
"name": "stdout",
2254+
"output_type": "stream",
2255+
"text": [
2256+
"3\n",
2257+
"4\n",
2258+
"7 1\n"
2259+
]
2260+
}
2261+
],
2262+
"source": [
2263+
"def somme_1(a,b):\n",
2264+
" print(a + b)\n",
2265+
"\n",
2266+
"def somme_2(a,b):\n",
2267+
" return a + b\n",
2268+
"\n",
2269+
"def somme_soustraction(a,b):\n",
2270+
" return a + b, a - b\n",
2271+
"\n",
2272+
"somme_1(1,2)\n",
2273+
"print(somme_2(1,3))\n",
2274+
"s, d = somme_soustraction(4,3)\n",
2275+
"print(s, d)"
2276+
]
2277+
},
2278+
{
2279+
"cell_type": "code",
2280+
"execution_count": 27,
22432281
"metadata": {},
22442282
"outputs": [],
2245-
"source": []
2283+
"source": [
2284+
"a,b,c = [int(i) for i in input(\"Donnez trois valeurs :\").split(\",\")]"
2285+
]
2286+
},
2287+
{
2288+
"cell_type": "code",
2289+
"execution_count": 28,
2290+
"metadata": {},
2291+
"outputs": [
2292+
{
2293+
"name": "stdout",
2294+
"output_type": "stream",
2295+
"text": [
2296+
"<class 'int'> 2 3\n"
2297+
]
2298+
}
2299+
],
2300+
"source": [
2301+
"print(type(a),b,c)"
2302+
]
2303+
},
2304+
{
2305+
"cell_type": "code",
2306+
"execution_count": 31,
2307+
"metadata": {},
2308+
"outputs": [
2309+
{
2310+
"name": "stdout",
2311+
"output_type": "stream",
2312+
"text": [
2313+
"Anas Dabaghi\n"
2314+
]
2315+
}
2316+
],
2317+
"source": [
2318+
"def fct(prenom, nom=\"Azdad\"):\n",
2319+
" print(prenom, nom)\n",
2320+
" \n",
2321+
"fct(\"Anas\", \"Dabaghi\")"
2322+
]
2323+
},
2324+
{
2325+
"cell_type": "code",
2326+
"execution_count": 33,
2327+
"metadata": {},
2328+
"outputs": [
2329+
{
2330+
"name": "stdout",
2331+
"output_type": "stream",
2332+
"text": [
2333+
"22 (1, 2, 3) {'a': 1, 'b': 2, 'c': 3}\n"
2334+
]
2335+
}
2336+
],
2337+
"source": [
2338+
"def fct2(age, *lt, **dict):\n",
2339+
" print(age, lt, dict)\n",
2340+
"\n",
2341+
"fct2(22,1,2,3,a=1,b=2,c=3)"
2342+
]
22462343
}
22472344
],
22482345
"metadata": {

0 commit comments

Comments
 (0)