一,中文單項選擇題(30分,每個3分)
- 1.下列哪個語句在Python中是非法的?
A、x = y = z = 1 B、x = (y = z + 1)
C、x, y = y, x D、x += y
- 2.關於Python記憶體管理,下列說法錯誤的是
A、變數不必事先宣告 B、變數無須先建立和賦值而直接使用
C、變數無須指定型別 D、可以使用del釋放資源
- 3、下面哪個不是Python合法的識別符號
A、int32 B、40XL C、self D、name
- 4、下列哪種說法是錯誤的
A、除字典型別外,所有標準物件均可以用於布林測試
B、空字串的布林值是False
C、空列表物件的布林值是False
D、值為0的任何數字物件的布林值是False
- 5、下列表示式的值為True的是
A、5+4j > 2-3j B、3>2>2
C、(3,2) ‘xyz’
- 6、Python不支援的資料型別有
A、char B、int C、float D、list
- 7、關於Python中的複數,下列說法錯誤的是
A、表示複數的語法是real + image j B、實部和虛部都是浮點數
C、虛部必須字尾j,且必須是小寫 D、方法conjugate返回複數的共軛複數
- 8、關於字串下列說法錯誤的是
A、字元應該視為長度為1的字串 B、字串以標誌字串的結束
C、既可以用單引號,也可以用雙引號建立字串 D、在三引號字串中可以包含換行回車等特殊字元
- 9、以下不能建立一個字典的語句是
A、dict1 = {} B、dict2 = { 3 : 5 } C、dict3 = {[1,2,3]: “uestc”} D、dict4 = {(1,2,3): “uestc”}
- 10、下列Python語句正確的是
A、min = x if x y ? x : y
C、if (x > y) print x D、while True : pass
二,英文單項選擇題(30分)
- 1.what gets printed? Assuming python version 2.x()
print type(1/2)
A. B. C. D. E.
- 2. What gets printed?()
1 2 |
nums = set([1,1,2,3,3,3,4]) print len(nums) |
A.1 B.2 C.4 D.5 E.7
- 3. What gets printed?()
123456789101112counter = 1def doLotsOfStuff():global counterfor i in (1, 2, 3):counter += 1doLotsOfStuff()print counter
A.1 B.3 C.4 D.7 E.none of the above
- 4. What gets printed?()
1 |
print r"nwoow" |
A.new line then the string: woow
B.the text exactly like this: r”nwoow”
C.the text like exactly like this: nwoow
D.the letter r and then newline then the text: woow
E.the letter r then the text like this: nwoow
- 5. Which numbers are printed?()
1 2 3 4 5 |
for i in range(2): print i for i in range(4,6): print i |
A.2, 4, 6 B.0, 1, 2, 4, 5, 6 C.0, 1, 4, 5 D.0, 1, 4, 5, 6, 7, 8, 9 E.1, 2, 4, 5, 6
- 6. What gets printed by the code snippet below?()
1 2 3 |
import math print math.floor(5.5) |
A.5 B.5.0 C.5.5 D.6 E.6.0
- 7. Assuming the filename for the code below is /usr/lib/python/person.py
and the program is run as: python /usr/lib/python/person.py
What gets printed?()
1 2 3 4 5 6 7 8 |
class Person: def __init__(self): pass def getAge(self): print __name__ p = Person()p.getAge() |
A.Person B.getAge C.usr.lib.python.person D.main E.An exception is thrown
- 8. What gets printed?()
123456names1 = ['Amir', 'Barry', 'Chales', 'Dao']if 'amir' in names1:print 1else:print 2
A.1 B.2 C.An exception is thrown
- 9. What gets printed?()
12345numbers = [1, 2, 3, 4]numbers.append([5,6,7,8])print len(numbers)
A.4 B.5 C.8 D.12 E.An exception is thrown
- 10. What gets printed?()
1234567kvps = { '1' : 1, '2' : 2 }theCopy = kvps.copy()kvps['1'] = 5sum = kvps['1'] + theCopy['1']print sum
A.1 B.2 C.6 D.10 E.An exception is thrown
三,shell筆試題(15分)
檔案如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# cat /etc/passwdroot:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin haldaemon:x:68:68:HAL daemon:/:/sbin/nologin gdm:x:42:42::/var/lib/gdm:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin apache:x:48:48:Apache:/var/www:/sbin/nologin saslauth:x:498:76:"Saslauthd user":/var/empty/saslauth:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin pulse:x:497:496:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin neil:x:500:500::/home/neil:/bin/bashtest:x:501:501::/home/test:/bin/bash yulian:x:503:503::/home/yulian:/bin/bash puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin jboss:x:504:504::/home/jboss:/bin/bash mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash release:x:505:505::/home/release:/bin/bash redis:x:496:493:Redis Server:/var/lib/redis:/sbin/nologin mongodb:x:184:492:MongoDB Database Server:/var/lib/mongodb:/sbin/nologin fang:x:506:506::/home/fang:/bin/bash roundup:x:495:491:Roundup Issue Tracker:/var/lib/roundup:/sbin/nologin exim:x:93:93::/var/spool/exim:/sbin/nologin dial:x:507:507::/home/dial:/bin/bash share:x:508:508::/home/share:/bin/bash |
請列印出使用者目錄在/home下面的的使用者目錄,如下
1 2 3 4 5 6 7 8 |
/home/neil /home/test /home/yulian /home/jboss /home/release /home/fang /home/dial /home/share |
建議一行搞定。
四,SQL筆試題(15分)
用一條SQL語句 查詢出每門課都大於80分的學生姓名 。表scores如下:
name kecheng fenshu
張三 語文 81
張三 數學 75
李四 語文 76
五,python筆試題(20分)
- 1,python常見的命令列互動自動化模組有哪些?(2分)
- 2,python的底層網路互動模組有哪些?(2分)
- 3,python網路互動時,二進位制打包解包的模組有哪些(2分)
- 4,python的測試框架有哪些?試列出常用的3個或更多(6分)
- 5,一行把[1,2,3,1,2,3] 中的重複元素剔除。(3分)
- 6,現在要你使用pyDes(DES加密)和標準庫中的namedtuple,假設你之前沒有接觸過,你如何快速上手? (5分)