for a in range(10000): time.sleep(10)
var = 1 while var == 1: n = input("请输入一个数") print(n) var += 10
while True: break
a = [3,-1,','] for i in a[:]: if 3 not in a: break
执行完下面代码后,输出的结果为( )
ls = [6, 1, 8, 6, 9, 6] n = len(ls) for i in range(n): for j in range(i+1,n): if ls[j]>ls[i]: tmp = ls[i] ls[i] = ls[j] ls[j] = tmp print(ls)
使用字典统计字符串中每个字符出现的次数,横线上应该填写的代码是
dic = {} for c in 'an apple a day keeps the doctor away': dic[c] = __________ print(dic)
阅读下面的代码,正确的输出是( )
x = ['N','O','C'] for i in x: x.append(i.lower()) print(x)
阅读下面程序,假设键盘输入666,正确的输出是( )
number = input() str(number) int(number) print(number+number)
666
1332
666666
某位初出茅庐的python初学者写出如下代码,程序执行后输出结果为
m = 2 if m//3 != 0: print(m,'不能被3整除') else: print(m,'能被3整除')
-19
0
2
4
阅读以下程序,请问运行结束后会显示的是( )
x, y, z = 10, 20, 40 x, y = z/x, z-y z = x*y print(z)
40.0
20.0
10.0
下列Python代码,在输入5时输出'Five'的是( )
x = input() if x==5: print('Five')
x = input() if x=5: print('Five')
x = input() if x=='5': print('Five')
x = input() if x='5': print('Five')
执行下面代码,最终输出的结果是( )
m, n = 6, 88 def fn(n): global m m += 100 n = 100 return m print(m,fn(n),n)
已知字符串s='Data Science',提取单词'Data'的选项是( )
逻辑器
已知变量赋值如下,以下选项中,结果为False的是( )
x = 15 y = 12
下面的程序输出的结果和原字符串一样( )
s = '上海自来水来自海上' print(s[:-1:])
下面Python代码执行后将输出[10,15,20]( )
ls = [] for i in range(10,20,5): ls.append(i) print(ls)
(多选)阅读下面代码,说法正确的是?
def transform(myls): tmp_ls = [] for num in myls: if num > 0 and num % 2 == 0: tmp_ls.append(num ** 2) elif num > 0 and num % 2 != 0: tmp_ls.append(num + 3) elif num < 0: tmp_ls.append(num * -1) return tmp_ls ls = [-2,2,3,-4,0,5,6] print(transform(ls))
(多选)列表中存储了中国神话中的五大神龙的名字,请问执行下面程序后,输出的结果含有哪些龙?
ls = ['烛龙','蟠龙','青龙','应龙','苍龙'] for i in range(2): ls.pop(i) print(ls)
for _ in range(4): t.forward(100) t.right(90)
for i in range(2): for j in range(4): t.forward(100) t.left(90)
n = 5 for i in range(n): t.forward(100) t.left(360/n)
for i in range(1,8,2): t.forward(-100) t.left(-90)
阅读下面代码,输出的结果是( )
ls = [x for x in range(9,0,-1)] x = ls.index(4) n = ls[-1] * x print(n)
阅读下面代码,输出的结果是( )
cnt = 0 for i in range(30): if i % 2: continue else: if i % 3 == 0 and i % 5 == 0: break cnt += i print(cnt)
运行以下代码,在键盘输入'NOC',则输出的结果是( )
s = input() s1 = '' for c in s: s1 = chr(ord(c)+32) + s1 print(s1)
阅读下面代码,输出的结果是( )
n = len('2023,2024,2025'.split(',')) print(n)
阅读下面代码,输出的结果是( )
def f(n): if n <= 1: return n return f(n-2)*2 - f(n-1) + n print(f(5))
以下程序,输出的结果是( )
mydict = {'小明':95,'小红':100} score = mydict.get('小白',0) print(score)
下面程序,重复执行6次循环,横线上需要填写的1个数是__
for i in range(2024,______): print(i)
Python面向对象程序中,定义一个类的关键字是:__
Python中的列表能够存储许多数据。如下list1列表存储了许多成语,现在想要找出所有第一个字为'天'的成语,并存储到list2列表。
list1 = ['霸王别姬','天长地久','皆大欢喜', '两小无猜','掌上明珠','偷天换日', '天上人间'] list2 = [] for s in list1: if ______ == '天': list2.append(s) print(list2)
以下程序模拟了用户登录功能,当用户输入的用户名和密码分别为noc2024和123456时,输出'登入成功',否则输出'登入失败'。
username = input('请输入用户名:') password = input('请输入密码:') if username == 'noc2024' and password == _____: print('登入成功') else: print('登入失败')