diff --git a/source/2021-01-25-first-post.md b/source/2021-01-25-first-post.md new file mode 100644 index 00000000..8ab1fd7e --- /dev/null +++ b/source/2021-01-25-first-post.md @@ -0,0 +1,35 @@ +title: 6歳にウケるPython +date: 2021-01-25 +tags: ["Python", "初投稿"] + +Gitpressでは、Code-knackという機能で、コードの実行ボタン付きのシンタックスハイライトが使えます +Code Pen に似ていますね + +とりあえずハロワから試してみましょう + +```python + +print('Hello Python!') + +``` + +6歳にウケるPythonのコードを紹介します + +```PYTHON + +r = input('すうじをいれてね(0~2):') + +print(r) + +if (r == '0') or (r == '1') or (r == '2'): + print ('いいすうじですね!') +else: + print ('すうじは、0,1,2のどれかにしてね') + +``` + +お子さんの好きな数字を聞いて、書き換えてあげましょう + + +参考記事: [【Web】Gitpressが凄い!いろんなコードを動かせる記事がかけるんだ Code-knakが凄いのか!?【Git】] +(https://tom2rd.sakura.ne.jp/wp/2019/06/20/post-9425/) diff --git "a/source/Python\343\201\253\343\202\210\343\202\213\350\253\226\347\220\206\346\274\224\347\256\227\343\201\256\343\202\267\343\203\263\343\203\227\343\203\253\343\201\252\345\256\237\350\243\205.md" "b/source/Python\343\201\253\343\202\210\343\202\213\350\253\226\347\220\206\346\274\224\347\256\227\343\201\256\343\202\267\343\203\263\343\203\227\343\203\253\343\201\252\345\256\237\350\243\205.md" new file mode 100644 index 00000000..b46aea1a --- /dev/null +++ "b/source/Python\343\201\253\343\202\210\343\202\213\350\253\226\347\220\206\346\274\224\347\256\227\343\201\256\343\202\267\343\203\263\343\203\227\343\203\253\343\201\252\345\256\237\350\243\205.md" @@ -0,0 +1,73 @@ +誰が要るのか知らないけれど +やってみるとちょっとおもしろい +論理演算のシンプルな実装です + + + +論理和(AND) +```python +def AND(x, y): + return bool(x and y) + +print(AND(0,0)) +print(AND(0,1)) +print(AND(1,0)) +print(AND(1,1)) +``` + +否定論理和(NAND) +```python +def NAND(x, y): + return bool(not x or not y) + +print(NAND(0,0)) +print(NAND(0,1)) +print(NAND(1,0)) +print(NAND(1,1)) + +#演算子がand →orに変化 +``` + +論理和(OR) +```python +def OR(x, y): + return bool(x or y) + +print(OR(0,0)) +print(OR(0,1)) +print(OR(1,0)) +print(OR(1,1)) +``` + +否定論理和(NOR) +```python +def NOR(x, y): + return bool(not x and not y) + +print(NOR(0,0)) +print(NOR(0,1)) +print(NOR(1,0)) +print(NOR(1,1)) + +#演算子がor →andに変化 +``` + +排他的論理和(XOR) +```python +def XOR(x, y): + return bool((x and not y) or (not x and y)) + +print(XOR(0,0)) +print(XOR(0,1)) +print(XOR(1,0)) +print(XOR(1,1)) +``` + +否定(NOT) +```python +def NOT(x): + return bool(not x) + +print(NOT(0)) +print(NOT(1)) +```