Files
hello-algo/ja/codes/python/chapter_hashing/built_in_hash.py
T
Yudong JinandClaude Opus 5.5 4fd605c502 Correct and unify doc snippets; fix errors in the demo sources (#2039)
Code snippets in the book are corrected and unified across languages and
kept as literal blocks in the snippet files. The demo sources keep their
#2033 form, with fixes only for real errors: wrong code, wrong printed
labels, comments that contradict the code, and typos. en/ja/ko demos are
rendered from the reviewed code dictionaries (krahets/hello-algo-workspace#78).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 15:29:13 +08:00

38 lines
926 B
Python

"""
File: built_in_hash.py
Created Time: 2023-06-15
Author: krahets ([email protected])
"""
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent))
from modules import ListNode
"""実行用コード"""
if __name__ == "__main__":
num = 3
hash_num = hash(num)
print(f"整数 {num} のハッシュ値は {hash_num}")
bol = True
hash_bol = hash(bol)
print(f"真偽値 {bol} のハッシュ値は {hash_bol}")
dec = 3.14159
hash_dec = hash(dec)
print(f"小数 {dec} のハッシュ値は {hash_dec}")
str = "Hello 算法"
hash_str = hash(str)
print(f"文字列 {str} のハッシュ値は {hash_str}")
tup = (12836, "小哈")
hash_tup = hash(tup)
print(f"タプル {tup} のハッシュ値は {hash_tup}")
obj = ListNode(0)
hash_obj = hash(obj)
print(f"ノードオブジェクト {obj} のハッシュ値は {hash_obj}")