Python 全國二級衝刺卷


衝刺試卷

【理論部分】

單選題 40題

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

Python 全國二級衝刺卷

【上機測試】程序題

(1)題目1

Python 全國二級衝刺卷

x = pow((3**4 + 5*(6**7))/8, 0.5)print("{:.3f}".format(x))

(2)題目2

Python 全國二級衝刺卷

import jieba

s = "中國特色社會主義進入新時代,我國社會主要矛盾已經轉化為人民日益增長的美好生活需要和不平衡不充分的發展之間的矛盾。"

n = __________

m = __________

print("中文字符數為{},中文詞語數為{}。".format(n, m))

import jieba s = "中國特色社會主義進入新時代,我國社會主要矛盾已經轉化為人民日益增長的美好生活需要和不平衡不充分的發展之間的矛盾。"

n = len(s)

m = len(jieba.lcut(s))

print("中文字符數為{},中文詞語數為{}。".format(n, m))

(3)題目3

Python 全國二級衝刺卷

print("二進制{____①____}、十進制{____②____}、八進制{____③____}、十六進制{____④____}".format(____⑤____))

print("二進制{0:b}、十進制{0}、八進制{0:o}、十六進制{0:x}".format(0x4DC0+50))

(4)題目4

Python 全國二級衝刺卷

# import turtle

# d = 0

# for i in range(____①____):

# turtle.fd(____②____)

# d = ____③____

# turtle.seth(d)

import turtle d = 0

for i in range(4): turtle.fd(200) d = d + 90 turtle.seth(d)

(5)題目5

Python 全國二級衝刺卷


ls = ["綜合", "理工", "綜合", "綜合", "綜合", "綜合", "綜合", "綜合", \\

"綜合", "綜合", "師範", "理工", "綜合", "理工", "綜合", "綜合", \\

"綜合", "綜合", "綜合", "理工", "理工", "理工", "理工", "師範", \\

"綜合", "農林", "理工", "綜合", "理工", "理工", "理工", "綜合", \\

"理工", "綜合", "綜合", "理工", "農林", "民族", "軍事"]

d = {}

for word in ls: d[word] = d.get(word, 0) + 1

for k in d: print("{}:{}".format(k, d[k]))

(6)題目6

Python 全國二級衝刺卷

Python 全國二級衝刺卷

參考答案1

fi = open("論語-網絡版.txt", "r", encoding="utf-8")

fo = open("論語-提取版.txt", "w")

wflag = False #寫標記for line in fi: if "【" in line: #遇到【時,說明已經到了新的區域,寫標記置否 wflag = False if "【原文】" in line: #遇到【原文】時,設置寫標記為True wflag = True continue if wflag == True: #根據寫標記將當前行內容寫入新的文件 for i in range(0,25): for j in range(0,25): line = line.replace("{}·{}".format(i,j),"**") for i in range(0,10): line = line.replace("*{}".format(i),"") for i in range(0,10): line = line.replace("{}*".format(i),"") line = line.replace("*","") fo.write(line)fi.close()fo.close()

參考答案2

fi = open("論語-提取版.txt", "r")

fo = open("論語-原文.txt", "w")

for line in fi: #逐行遍歷 for i in range(1,23): #對產生1到22數字 line=line.replace("({})".format(i), "") #構造(i)並替換 fo.write(line)fi.close()fo.close()


分享到:


相關文章: