From aa654669f17a76c1118455d0539181d415fd9a49 Mon Sep 17 00:00:00 2001 From: jackfrued Date: Mon, 9 Jul 2018 15:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=9D=A2=E8=AF=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...42\350\257\225\346\214\207\345\215\227.md" | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 "\351\235\242\350\257\225\346\214\207\345\215\227.md" diff --git "a/\351\235\242\350\257\225\346\214\207\345\215\227.md" "b/\351\235\242\350\257\225\346\214\207\345\215\227.md" new file mode 100644 index 0000000..3d5b40f --- /dev/null +++ "b/\351\235\242\350\257\225\346\214\207\345\215\227.md" @@ -0,0 +1,67 @@ +## 面试指南 + +### 基础知识 + +1. 下面的代码会输出什么。 + + ```Python + + list1 = [1, 2, 3, 4] + + list2 = [i for i in list1 if i > 2] + print(list2) + + list3 = [i for i in list1 if i % 2] + print(list3) + + dict1 = {x: x ** 2 for x in (2, 4, 6)} + print(dict1) + + dict2 = {x: f'item{x ** 2}' for x in (2, 4, 6)} + print(dict2) + + set1 = {x for x in 'hello world' if x not in 'abcdefg'} + print(len(set1)) + ``` + +2. 下面的代码会输出什么。 + + ```Python + + num = 100 + + + def foo(): + num = 200 + + + def bar(): + print(num) + + + bar() + foo() + bar() + ``` + +3. 如何修改下面的Python代码,才能够输出“foo in father”? + + ```Python + + class Father(object): + + def foo(self): + print('foo in father.') + + + class Son(object): + + def foo(self): + print('foo in son.') + + + obj = Son() + obj.foo() + ``` + +4. \ No newline at end of file -- GitLab