python期末考试试题汇总

您所在的位置:网站首页 大学期末考试顺序 python期末考试试题汇总

python期末考试试题汇总

2024-07-16 09:30| 来源: 网络整理| 查看: 265

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:\\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 b6 else (6 if 3>2 else 5)的值为__6__。

76.表达式 len(range(1,10))的值为__9__。

77.表达式 'abcab'.replace('a','yy')的值为__'yybcyyb'__。

78.Python标准库math中用来计算平方根的函数是__sqrt()__。

79.以下程序的输出结果是(('bird,fish,monkey,rabbit,tiger,','monkey','')):

s='bird,fish,monkey,rabbit,tiger,monkey'

print(s.rpartition("monkey"))

80.int(2>>__。

83.表达式':'.join('1,2,3,4,5'.split(','))的值为__'1:2:3:4:5'__。

84.eval()函数可以将__字符串__解析成数值。

85.表达式min(['11','2','3'])的值为__'11'__。

86.print("{:=



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3