#QKCP300. QKCP301~310

QKCP301~310

1、执行以下代码,打印输出的内容是?( )。

for i in "python":
    if i == "h":
        continue
    print(i, end="")

{{ select(1) }}

  • pyton
  • python
  • p
  • ython

2、若有变量定义如下,下列选项中,可以得到整型数字5的是?( )。

a = 7
b = "Hi"
c = ["Hi", "55"]

{{ multiselect(2) }}

  • a - len(b)
  • len(b) - a
  • a - len(c)
  • int(a - int(c[1][1]))+3

3、在横线处增加一行代码,使程序能够输出字符"Python"( )。

word = "Python"
temp = ""
for i in word:
    ________
    print(temp)

{{ multiselect(3) }}

  • temp += i
  • temp = word
  • temp = temp*2
  • temp += i*2

4、执行下列程序,那么multiply(4, 3)返回的结果是( )?( )。

def multiply(x, y):
    return x*y
    result = multiply(4, multiply(3, 2))
    return result

{{ select(4) }}

  • 12
  • 24
  • 6
  • 没有返回结果

5、下列选项中,符合Python变量命名规范的是?( )。 {{ multiselect(5) }}

  • _myvar
  • 2things
  • thisList
  • var!

6、运行下列程序,输出的内容是?( )。

index = 3
numbers = [1, 2, 3, 4, 5]
if index in numbers:
    print(numbers[index])
else:
    print("Not found")

{{ multiselect(6) }}

  • 3
  • 4
  • Not found
  • Error

7、运行下列程序,输出的内容包括是?( )。

fruits = ["apple", "banana", "cherry"]
fruits.remove("banana")
print(fruits)

{{ multiselect(7) }}

  • 'apple'
  • 'banana'
  • 'cherry'
  • ['apple', 'cherry']

8、运行下列程序,最终输出的内容可能是?( )。

from random import *
num_dict = {1: "one", 2: "two", 3: "three"}
del num_dict[2]
num_dict[4] = "four"
sum1 = randint(1, 10)
for key, values in num_dict.items():
    sum1 = sum1 + key
print(sum1)

{{ multiselect(8) }}

  • 8
  • 9
  • 29
  • 12

9、在Python中,关于算术运算符和逻辑运算符的说法正确的是?( )。 {{ multiselect(9) }}

  • 算术运算符优先预逻辑运算符
  • 逻辑运算符 and 优先于 or
  • "+"运算符可以用于字符串拼接
  • not 运算符优先级最高

10、关于函数定义和使用的陈述中,正确的是?()

{{ multiselect(10) }}

  • 函数一旦定义,在程序中不可以更改
  • 在Python中,可以使用def关键字来定义一个函数
  • 函数可以有参数,也可以没有
  • 函数必须返回一个值