count = 0
with open("text.txt", "r") as f:
content = f.________ # 补全代码
words = content.split()
for word in words:
if word == "Python":
count += 1
print("Python出现次数:", count)
2分
登录后查看选项
11
以下代码的时间复杂度是?
def func(n):
sum = 0
for i in range(n):
for j in range(i):
sum += j
def insertion_sort_optimized(arr):
n = len(arr)
for i in range(1, n):
key = arr[i] # 当前待插入元素
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j] # 元素后移
j -= 1
_______________ # 插入元素到正确位置
2分
登录后查看选项
14
阅读以下 Python 代码,下列说法正确的是?
n = int(input())
def is_palindrome(s):
return s == s[::-1]
max_palindrome = 0
for i in range(10 ** (n - 1), 10 ** n):
for j in range(i, 10 ** n):
product = i * j
if is_palindrome(str(product)) and product > max_palindrome:
max_palindrome = product
print(max_palindrome)