<jupyter_start><jupyter_text>代入<jupyter_code>a = 1
b = 'x'<jupyter_output><empty_output><jupyter_text>配列<jupyter_code>x = [1,"2"]
x.append(3)
print(x)
print(x[0])<jupyter_output>[1, '2', 3]
1<jupyter_text>if<jupyter_code>a = 1
if a == 2:
    print("a == 2")
elif a == 3:
    print("a == 3")
else:
    print("other")<jupyter_output>other<jupyter_text>for<jupyter_code>a = [5,6,7,8]
for x in a:
    print(x)<jupyter_output>5
6
7
8<jupyter_text>リストの内包表現<jupyter_code>a = [1,2,3,4]
b = [x*2 for x in a]
print(a)
print(b)<jupyter_output>[1, 2, 3, 4]
[2, 4, 6, 8]<jupyter_text>辞書<jupyter_code>a = {"one":1, "two":2, "three":3}
print(a["one"])
print(a["two"] + a["three"])<jupyter_output>1
5<jupyter_text>辞書の内包表現<jupyter_code>a = [1,2,3,4]
b = ["one","two","three","four"]
c = {key:value for value,key in zip(a,b)}
print(a)
print(b)
print(c)<jupyter_output>[1, 2, 3, 4]
['one', 'two', 'three', 'four']
{'one': 1, 'two': 2, 'three': 3, 'four': 4}<jupyter_text>関数<jupyter_code>def func1(a):
    return a**2
print(func1(10))

def func2(a=5):
    return a**2
print(func2())<jupyter_output>100
25<jupyter_text>よく使う組み込み関数print, range, len, zip, int, float, fString, rawString<jupyter_code>print("----")
print("10", "11", "12")

print("----")
for i in range(10):
    print(i)

print("----")
a = [5,6,7,8]
print(len(a))

print("----")
for i,j in zip(range(0,10), range(10,20)):
    print(i, j)

print("----")
print(int("10"))
print(float(5))

print("----")
print(f'variable a is {a}.')

print("----")
print('new line is \n.')
print(r'new line is \n.')
print(r'D:\document\git\github\kota\work\puruneko\python')<jupyter_output>----
10 11 12
----
0
1
2
3
4
5
6
7
8
9
----
4
----
0 10
1 11
2 12
3 13
4 14
5 15
6 16
7 17
8 18
9 19
----
10
5.0
----
variable a is [5, 6, 7, 8].
----
new line is 
.
new line is \n.
D:\document\git\github\kota\work\puruneko\python<jupyter_text>オブジェクト指向とクラス関連のあるデータと機能をひとまとめにしたもの* クラス：データと機能をどのようにひとまとめにするか記述したもの（＝ひな形）* インスタンス：クラスに対して具体的に値を入れて（初期化して）実際に使えるようにしたもの（＝実態）Personクラス* 名前と年齢を入れると、いろんな情報を返してくれる<jupyter_code>class PersonClass():
    def __init__(self, name, age):
        self.name = name
        self.age = age
    
    def age_details(self):
        if self.age < 3:
            return "赤ちゃん"
        elif self.age < 6:
            return "幼稚園児"
        elif self.age < 13:
            return "小学生"
        elif self.age < 16:
            return "中学生"
        elif self.age < 19:
            return "高校生"
        elif self.age < 23:
            return "大学生"
        else:
            return "大人"
    
    def description(self):
        result = ""
        result += f"氏名：{self.name}\n"
        result += f"年齢：{self.age}歳({self.age_details()})"
        return result

person_instance = PersonClass("有田龍太郎", 30)
print(person_instance.description())<jupyter_output>氏名：有田龍太郎
年齢：30歳(大人)
{'fraction_non_alphanumeric': 0.20021413276231265, 'fraction_numerical': 0.05603140613847252, 'mean_word_length': 3.428120063191153, 'pattern_counts': {'":': 3, '<': 38, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '460418', 'license': 'MIT', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1390, 'n_words': 251, 'path': 'work/puruneko/python/sample.ipynb', 'repo_name': 'puruneko/sevenBridge_game', 'size': '2802'}