没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
33页
python考试题目及答案-python期末考试试题汇总 6.for i in range(2,n): if n%i==0:break if i==n-1: print('是素数') else: print('不是素数') 7.'abcabcabc'.count('abc')的值为__3__。 8.对于有else子句的for循环和while循环,但循环因循环条件不成立而自然结束时__会 __(会或不会)执行else中的代码。 10.已知x='hello world.',那么表达式x.find('x')和x.rfind('x')的值都为__-1__。 12.print("{:#>4d}".format(23))的输出结果是__##23__。 13.以下哪个选项不是Python中的合法名称(2_g):_ag,a_g,ag_,2_g 14.以下哪个选项是python中的合法名称(num_1):2num,num-1,num_1,num 1 15.print(3+5)语句的运行结果是(8) 16.print(2**4+16%3) __17__ 17.以下程序的输出结果是__0__。 a=8 a%
资源推荐
资源详情
资源评论
python 考试题目及答案-python 期末考试试题汇总
第 1 页 共 33 页
python 考试题目及答案-python 期末考试试题汇总
6.for i in range(2,n):
if n%i==0:break
if i==n-1:
print('是素数')
else:
print('不是素数')
7.'abcabcabc'.count('abc')的值为__3__。
8.对于有 else 子句的 for 循环和 while 循环,但循环因循环条件不成立而自然结束时__会
__(会或不会)执行 else 中的代码。
10.已知 x='hello world.',那么表达式 x.find('x')和 x.rfind('x')的值都为__-1__。
12.print("{:#>4d}".format(23))的输出结果是__##23__。
13.以下哪个选项不是 Python 中的合法名称(2_g):_ag,a_g,ag_,2_g
14.以下哪个选项是 python 中的合法名称(num_1):2num,num-1,num_1,num 1
15.print(3+5)语句的运行结果是(8)
16.print(2**4+16%3) __17__
17.以下程序的输出结果是__0__。
a=8
a%=2
print(a)
18.print("**"*3)的输出结果是(******)。
19.表达式 True and False 的值为:__False__。
20.以下程序的输出结果是(7)
python 考试题目及答案-python 期末考试试题汇总
第 2 页 共 33 页
x=371
print(x%100//10)
21.a,b=1,2 则 a 的值为__1__。
22.在循环语句中,__continue___语句的作用是提前结束本层循环。
23.表达式"abc10'.isalnum()的值为__True__。
24.表达式 True*3 的值为 __3__。
25.表达式'c:\windows\notepad.exe'.endswith('.exe')的值为__True__。
26.表达式'test.py'.endswith('.py')的值为__True__。
27.表达式 int('123')的值为__123__。
28.表达式 'Beautifule is better than ugly.'.startswith('Be',5)的值为__False__。
29.假设 a,b=10,50,则条件表达式 a>10 and b<100 的值为__False_____。
30.python3.x 语句 for i in range(3):print(i,end=',')的输出结果为__0,1,2,__。
31.程序的基本结构:__顺序结构、选择结构和循环结构__。
32.在 python 语言内置的 random 库中,哪个函数功能是从序列 s 中随即选择一个元素(A):
A、choice(s),B、randint(m,n),C、shuffle(s),D、uniform(m,n)
33.以下程序的输出结果(3
5)
print(3,end="")
print()
print(5)
34.表达式 int(False)的值为:__0__。
35.以下程序的输出结果是(-3)
python 考试题目及答案-python 期末考试试题汇总
第 3 页 共 33 页
a=-8
a//=3
print(a)
36.print(15%4)的输出结果是(3)
37.有 python 语句:
for s in "abced":
print(s,end=' ')
的运行结果是(a b c d e)。
38.print("{:&>8}".format("python"))的输出结果是($$python)
39.有 python 语句:
for i in range(100,999+1):
a=i//100
b=i//10%10
c=i%10
if a**3 + b**3 + c**3 == i:
print(i,end=" ")
的运行结果是(153 370 371 407)。
40.下列 Python 语句:
x,y=30,70
min = x if x
print(min)
的运行结果是(30)。
python 考试题目及答案-python 期末考试试题汇总
第 4 页 共 33 页
41.表达式'abc' in ('abcdefg')的值为__True__。
42.已知 x,y=3,5,那么执行 x,y=y,x 之后,x 的值为__5__。
43.表达式'aaasdf'.strip('a')的值为__'sdf'__。
44.已知 x=3,那么执行语句 x += 6 之后,x 的值为__9__。
45.python 用于表示逻辑与运算的关键字是__and__。
46.表达式 int(4**0.5)的值为__2__。
47.表达式 len('aaaassddf'.strip('afds'))的值为__0__。
48.在循环语句中,__continue__语句的作用是提前进入下一次循环。
49.Python 标准库 random 中的__choice()__方法作用是从序列中随机选择 1 个元素。
50.已知 x=3,那么执行语句 x*=6 之后,x 的值为__18__。
51.以下程序的输出结果是(9630)。
s="0123456789"
print(s[::-3])
52.在 python 语句中,条件表达式中判断相等用的关系运算符是(==)。
53.表达式 chr(ord('A')+2)的值为__'C'__。
54.表达式 sum(range(10))的值为__45__。
55.x=-9
print(x) if x>=0 else print(-x)
的输出结果为__9__。
56.python 的内置函数__len()__可以返回列表、元组、字典、集合、字符串以及 range 对
象中元素个数。
57.表达式'apple.peach,banana,pear'.find('p')的值为__1__。
58.表达式 len('SDIBT')的值为__5__。
python 考试题目及答案-python 期末考试试题汇总
第 5 页 共 33 页
59.表达式':'.join('hello world.'.split())的值为__'hello:world.'__。
60.python 语句''.join(list('hello world!'))执行的结果是__'hello world!'__。
61.表达式 3 or 5 的值为__3__。
62.表达式 16**0.5 的值为 __4.0__。
63.有关 for 循环和 while 循环的退出(有两种方式:一是循环条件不成立或循环序列遍历结
束,二是在循环过程中遇到 break 语句)。
64.分支结构的类型:单分支、双分支、多分支和嵌套 if 结构。
65.关于多分支结构 if-elif-else 语句的说法正确的是:最多只会执行一个分支。
66.表达式 not (True and False)的值为(True)。
67.s.islower()方法是用来:判断字符串 s 中的字母是否全为小写。
68.以下程序的输出结果为(bird-fish-monkey-rabbit)
s=['bird','fish','monkey','rabbit']
print("-".join(s))
69.python 语言的运行方式有__交互__式和文件式两种。
70.表达式'a'+'b'的值为 __'ab'__。
71.表达式'Hello world'.lower()的值为__'hello world'__。
72.表达式 1234%1000//100 的值为__2__。
73.表达式'abc10'.isdigit()的值为__False__。
74. 表 达 式 'hello world, hellow every one'.replace('hello','hi') 的 值 为 __'hi
world, hiw every one'__。
75.表达式 5 if 5>6 else (6 if 3>2 else 5)的值为__6__。
76.表达式 len(range(1,10))的值为__9__。
77.表达式 'abcab'.replace('a','yy')的值为__'yybcyyb'__。
剩余32页未读,继续阅读
资源评论
是空空呀
- 粉丝: 168
- 资源: 3万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功