2020年《python程序设计》基础知识及程序设计598题GS[含参考答案].docxVIP

  • 86
  • 0
  • 约4.74千字
  • 约 6页
  • 2021-02-06 发布于天津
  • 举报

2020年《python程序设计》基础知识及程序设计598题GS[含参考答案].docx

2020年《 python 程序设计》基础知识及程序设计 598 题[含参考答案 ] 一、填空题 1.表达式 Hello world![-4:] 的值为 。( rld! ) 2. 已知 table = .maketrans(abcw, xyzc) ,那么表达式 Hellow world.translate(table) 的值为 。( Helloc corld ) 3.表达式 chr(ord(A)+2) 的值为 。( C) 表达式 len(中国.encode(gbk))的值为 。( 4) 表达式 len(中国.encode(utf-8))的值为 。( 6) 当在字符串前加上小写字母 或大写字母 表示原始字符串,不对其中的任何字 符进行转义。( r.R) 代码 print(re.match(A[a-zA-Z]+$,abcDEFGOOO)) 的输出结果为 。( None) 表达式 C:\\Windows\\notepad.exe.startswith(C:) 的值为 。 ( True) 表达式 test.py.endswith((.py, .pyw)) 的值为 。 ( True) 正则表达式元字符 用来表示该符号前面的字符或子模式 1 次或多次出现。 (+) 11 . 假 设 re 模 块 已 导 入 , 那 么 表 达 式 re.findall((\d)\\1+, 33abcd112) 的 值 为 。 ( [3, 1]) 12. 表达式 .join(re.split([sd],asdssfff)) 的值为 。 ( afff ) 13 .已知 x = a234b123c,并且re模块已导入,则表达式re.split(\d+, x)的值为 。 ( [a, b, c] ) 14. 表达式 re.split(\.+, alpha.beta...gamma..delta) 的值为 。 [alpha, beta, gamma, delta] ) 15.已知 x = 123 和 y = 456 ,那么表达式 x + y 的值为 。( 123456) 16.表达式 a + b 的值为 。( ab) 17. 字符串编码格式 GBK 使用 个字节表示一个汉字。( 2) 18.表达式 len(abc.ljust(20)) 的值为 。( 20) 19. 假设 math 标准库已导入,那么表达式 eval(math.sqrt(4)) 的值为 。( 2.0) 20 . Python 中 用 于 表 示 逻 辑 与 . 逻 辑 或 . 逻 辑 非 运 算 的 关 键 字 分 别 是 . . 。( and.or.not) 21.已知 x = abcdefg,则表达式 x[3:] + x[:3]的值为 。( ’defgabc) 22. 表达式 aaasdf.rstrip(af) 的值为 。 ( aaasd) 表达式 aaasdf.strip(af) 的值为 。 ( sd) 表达式 aaasdf.lstrip(af) 的值为 。 ( sdf) 表达式 aaasdf.lstrip(as) 的值为 。 ( df) 表达式 %s%[1,2,3] 的值为 。 ( [1, 2, 3]) 27 . 表 达 式 hello world, hellow every one.replace(hello, hi) 的 值 为 。( hi world, hiw every one ) 已知 x 为非空列表,那么表达式 random.choice(x) in x 的值为 。( True) 已知字符串 x = hello world ,那么执行语句 x.replace(hello, hi) 之后, x 的值为 。 ( hello world ) 表达式 eval(__import__(math).sqrt(3**2+4**2)) 的值为 。 ( 5.0) 表达式 eval(__import__(math).sqrt(9)) 的值为 。( 3.0) 32. 代码 for i in range(3):print(i, end=,) 的执行结果为 。( 0,1,2,) 33. 表达式 abc.txt.endswith((.txt, .doc, .jpg)) 的值为 。( True) 34.表达式 [str(i) for i in range(3)] 的值为 。( [0, 1, 2]) 35. 已知 x = a b c d ,那么表达式 ,.join(x.split()) 的值为 。( a,b,c,d) 36. 表达式 rc:\windows\notepad.exe.endswith((.jpg, .exe)) 的值

文档评论(0)

1亿VIP精品文档

相关文档