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)
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:\'.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)
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多线程登录
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__。
conversationalist46.表达式 int(4**0.5)的值为__2__。
47.表达式len('aaaassddf'.strip('afds'))的值为__0__。
python基础代码100例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__。
59.表达式':'.join('hello world.'.split())的值为__'hello:world.'__。
60.python语句''.join(list('hello world!'))执行的结果是__'hello world!'__。
61.表达式 3 or 5 的值为__3__。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。