File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ ## 面试指南
2+
3+ ### 基础知识
4+
5+ 1 . 下面的代码会输出什么。
6+
7+ ``` Python
8+
9+ list1 = [1 , 2 , 3 , 4 ]
10+
11+ list2 = [i for i in list1 if i > 2 ]
12+ print (list2)
13+
14+ list3 = [i for i in list1 if i % 2 ]
15+ print (list3)
16+
17+ dict1 = {x: x ** 2 for x in (2 , 4 , 6 )}
18+ print (dict1)
19+
20+ dict2 = {x: f ' item { x ** 2 } ' for x in (2 , 4 , 6 )}
21+ print (dict2)
22+
23+ set1 = {x for x in ' hello world' if x not in ' abcdefg' }
24+ print (len (set1))
25+ ```
26+
27+ 2 . 下面的代码会输出什么。
28+
29+ ``` Python
30+
31+ num = 100
32+
33+
34+ def foo ():
35+ num = 200
36+
37+
38+ def bar ():
39+ print (num)
40+
41+
42+ bar()
43+ foo()
44+ bar()
45+ ```
46+
47+ 3 . 如何修改下面的Python代码,才能够输出“foo in father”?
48+
49+ ```Python
50+
51+ class Father (object ):
52+
53+ def foo (self ):
54+ print (' foo in father.' )
55+
56+
57+ class Son (object ):
58+
59+ def foo (self ):
60+ print (' foo in son.' )
61+
62+
63+ obj = Son()
64+ obj.foo()
65+ ```
66+
67+ 4 .
You can’t perform that action at this time.
0 commit comments