python考试题目及答案

您所在的位置:网站首页 python编程题目答案及分析 python考试题目及答案

python考试题目及答案

2023-08-11 08:21| 来源: 网络整理| 查看: 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 b=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__。

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'__。

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