<jupyter_start><jupyter_text>来，挑战一套Python面试题  下面的 Python 代码会输出什么<jupyter_code>print([(x, y) for x, y in zip('abcd', (1, 2, 3, 4, 5))])
print({x: f'item{x ** 2}' for x in range(5) if x % 2})
print(len({x for x in 'hello world' if x not in 'abcdefg'}))
from functools import reduce

items = [11, 12, 13, 14]
print(reduce(int.__mul__, map(lambda x: x // 2,
                              filter(lambda x: x ** 2 > 150, items))))<jupyter_output>42<jupyter_text>写一个函数，该函数的参数是一个列表，如果列表中的有三个元素相加之和为 0，就将这个三个元素组成一个三元组，最后该函数返回一个包含了所有这样的三元组的列表。<jupyter_code>def foo(array):
    for x in range(len(array)):
        for y in range(x+1, len(array)):
            for z in range(y+1, len(array)):
                if array[x] + array[y] + array[z] == 0:
                    print(x, y, z)

foo([-1, 0, 1, 2, -1, -4])<jupyter_output>0 1 2
0 3 4
1 2 4<jupyter_text>用 5 个线程，将 1 \~ 100 的整数累加到一个初始值为 0 的变量上，每次累加时将线程 ID 和本次累加后的结果打印出来。<jupyter_code>import threading


class MyThread(threading.Thread):
    def __init__(self):
        super(MyThread, self).__init__()

    def run(self):
        print(sum(range(1, 100)) + self.ident)


for x in range(5):
    MyThread().start()<jupyter_output>6474
17214
6006
16686
19034
{'fraction_non_alphanumeric': 0.15133779264214048, 'fraction_numerical': 0.06354515050167224, 'mean_word_length': 3.400735294117647, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '638180', 'license': 'MIT', 'n_tokens_mistral': 617, 'n_tokens_neox': 578, 'n_words': 124, 'path': 'code/zhihu_python3_interview.ipynb', 'repo_name': 'taseikyo/arts', 'size': '1196'}