From 2b28e2a8c3dbd67f8fe7ef2caa27f7f3308edb58 Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Wed, 27 Nov 2019 17:26:30 +0100 Subject: [PATCH 1/5] tenary operator --- 8/tenary_operator.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/8/tenary_operator.md b/8/tenary_operator.md index e69de29..49c4412 100644 --- a/8/tenary_operator.md +++ b/8/tenary_operator.md @@ -0,0 +1,18 @@ +# Tenarni operator +Unarni operatory jsou operatory ktery berou 1 vstup. Napriklad `not` je unarni operator. + +Binarni operatory jsou operatory ktery berou 2 vstupy. Napriklad `+` je binarni operator. + +Tenarni operator je operator ktery bere 3 vstupy. Ten je v pythonu tedy jenom jeden vypada takto: +```python +n = 2 # nejaky cislo +print("sudy" if n % 2 == 0 else "lichy") # vypise `sudy` protoze n je sudy +``` +coz je ekvivalence: +```python +n = 2 +if n % 2 == 0: + print("sudy") +else: + print("lichy") +``` From cfb480f7c16c68519c005d42381d2d129696c88f Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Wed, 27 Nov 2019 17:41:39 +0100 Subject: [PATCH 2/5] update --- 8/dict.md | 1 + 8/importy.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/8/dict.md b/8/dict.md index e69de29..e7c4f76 100644 --- a/8/dict.md +++ b/8/dict.md @@ -0,0 +1 @@ +# Dict diff --git a/8/importy.md b/8/importy.md index e69de29..fc2aa64 100644 --- a/8/importy.md +++ b/8/importy.md @@ -0,0 +1,54 @@ +# Importy +Importy nam slouzi k organizaci kodu nebo pouzivani kodu kterej napsal nekdo jinej. + +# Importovani vlastniho kodu + +Rekneme ze mate takovouhle slozku: +``` +. +├── lib.py +└── main.py +``` +lib.py: +```python +def hello(jmeno): + return "hello " + jmeno + +print("tohle je modul lib.py") # pozor; tohle se spusti, hned vysvetlim +``` +main.py: +```python +import lib # ne `import lib.py` + +print(lib.hello("world")) # ne `hello("world")` ale `lib.hello("world")` +``` +Kdyz pak udelame `python main.py` a spustime tim program tak dostaneme: +``` +tohle je modul lib.py # <- tohle dostaneme protoze pri importu se `lib.py` jakoby spusti, to ale nechceme +hello world # <- tohle je vystup z main.py, to co jsme chteli +``` +Prave proto si davejte pozor co pisete do veci ktery pak importujete, idealne by neco mel delat jenom +jeden soubor a zbytek by mel byt plny funkci (nic nedelat) abyste se nedostali k situaci kdy +se vam neco posralo hledate to mezi vsema python souborama. + +# Importovani cizicho kodu + +Cizi kod muzeme ziskat tim, ze si ho stahneme pomoci `pip`u z oficialnich repositari python moduluu. + +Ukazeme si to na prikladu modulu `requests`, ktery nam dovoluje vyrizovat http requesty v pythonu. + +Zacneme tim ze si ho stahneme: +```shell +pip install requests +``` +nebo na nekterych kompech: +```shell +python -m pip install requests +``` +Pak pockame az se stahne requests a muzeme pouzivat: + +```python +import requests + +requests +``` From 6e2e028206030c39a323090bf82bf8280219ff4b Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Wed, 27 Nov 2019 17:44:48 +0100 Subject: [PATCH 3/5] importy done --- 8/importy.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/8/importy.md b/8/importy.md index fc2aa64..75dc2bf 100644 --- a/8/importy.md +++ b/8/importy.md @@ -50,5 +50,7 @@ Pak pockame az se stahne requests a muzeme pouzivat: ```python import requests -requests +a = requests.get("https://raw.githubusercontent.com/Dawidkubis/python-gjk/master/8/importy.md") +print(a.text) ``` +Schvalne zkuste co vam to vypise :D From bfdd02fbc9a9adab625fb1e05146ba9ebe29ea04 Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Wed, 27 Nov 2019 17:46:12 +0100 Subject: [PATCH 4/5] . --- 8/dict.md | 2 ++ 8/requests_and_http.md | 0 2 files changed, 2 insertions(+) create mode 100644 8/requests_and_http.md diff --git a/8/dict.md b/8/dict.md index e7c4f76..7491f69 100644 --- a/8/dict.md +++ b/8/dict.md @@ -1 +1,3 @@ # Dict + +Vskrna dopln pls diff --git a/8/requests_and_http.md b/8/requests_and_http.md new file mode 100644 index 0000000..e69de29 From 060b80ea05972155f2d68e0ddf16638d179bed07 Mon Sep 17 00:00:00 2001 From: "Dawid J. Kubis" Date: Wed, 27 Nov 2019 17:47:38 +0100 Subject: [PATCH 5/5] . --- 8/requests_and_http.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/8/requests_and_http.md b/8/requests_and_http.md index e69de29..c7a6d8a 100644 --- a/8/requests_and_http.md +++ b/8/requests_and_http.md @@ -0,0 +1,2 @@ +# Http +Http je zpusob komunikace ktery se pouziva na siti.