青少年软件编程(python五级)等级考试试卷-客观题(2023年5月)
UK
'lili','张三'
lili
'UK','china','lili'
print(list(range(15, -1, 1)))
print(list(range(-1, 15, 1)))
print(list(range(15, 1, -1)))
print(list(range(15, 0, -1)))
li = s.split("l",0)
li = s.split("l",1)
li = s.split("l",2)
li = s.split("l",3)
cd
12
34
程序出现错误
“{1,2} {5,6}”是错误的语句
s数据类型是集合
此程序段的作用是输出原始集合s和移除数据之后的集合s
s数据类型是字典
print(borrow[1:n-2])
print(borrow[0:n-1])
print(borrow[:-2])
print(borrow[::-2])
sensor.insert('hongwai')
sensor.append('hongwai')
inset sensor['hongwai']
append sensor['hongwai']
\\b
\\n
\\t
\\r
print(S.find('o',1))
print(S.index('o'))
print(S.index('o',0,len(S)))
print(S.count('o'))
计算并输出10000以内的质数
计算并输出10000的约数
计算并输出10000的倍数
计算并输出1-10000以内的整10数
2, 4, 6, 8
[2, 4, 6, 8]
[1, 3, 5, 7, 9]
1, 3, 5, 7, 9
键
值
键-值
字典
A & B
A | B
A - B
B - A
print([for x in range(0, 100) if x % 7 == 0 and x % 3 != 0])
print([for x in range(1, 101) if x % 7 == 0 and x % 3 != 0])
print([x for x in range(0, 100) if x % 3 == 0 and x % 7 != 0])
print([x for x in range(1, 101) if x % 7 == 0 and x % 3 != 0])
print(time.ctime('%y%m%d'))
print(time.strftime('%y%m%d'))
print(time.nowdate('%y%m%d'))
print(time.local('%y%m%d'))
print(random.uniform(1,100))
print(random.randint(1,100))
print(random.sample(1,100))
print(random.shuffle(1,100))
sum(lst)
min(lst)
max(lst)
MIN(lst)
['a', 'b', 1, 2, 3, 'china', 'UK']
(('a','b'),(1,2,3),('china','UK'))
('a', 'b', 1, 2, 3, 'china', 'UK')
'a', 'b', 1, 2, 3, 'china', 'UK'
print((str1(0,0))
print(str1[::-1])
print(str1[0])
print(str1[0:5])
0-6
0-5
1-6
1-5
['2^10': 1024]
{"2^10"}
1024
{'2^10': 1024}
集合推导公式
字符串推导公式
列表推导公式
元组推导公式
(36,49,64)
{64, 49, 36}
{64,49}
{2,36,64}
'大'',''家', '好', ',', '我', '叫', '龙'',''云', '!', '请', '多多','关照', '!'
['大家', '好', ',', '我', '叫', '龙'',''云', '!', '请', '多多关照', '!']
['大家', '好', ',', '我', '叫', '龙云', '!', '请', '多多关照', '!']
('大家', '好', ',', '我', '叫', '龙云', '!', '请', '多多关照', '!')
10.20
10.0
11
10
发表评论 取消回复