青少年软件编程(Python五级)等级考试试卷(2022年12月)
tuple1=["张三","李四","王五"]
tuple1=("张三";"李四";"王五")
tuple1=(张三,李四,王五)
tuple1=("张三",)
print(tuple1(1:3))
print(tuple1[1::2])
print(tuple1[1,3])
print(tuple1[2:4])
list1 = []\nfor i in range(1,10,2):\n list1.append("data{}".format(i))\nprint(list1)
list2 = [ "data{}".format(i)for i in range(1,10,2)]\nprint(list2)
list3= []\nfor i in range(10):\n if i %2 == 1:\n list3.append("data{}".format(i))\nprint(list3)
list4 = [ "data{}".format(i) for i in range(0,10) if i % 2 == 0]\nprint(list4)
yield作为Python的关键字之一,在生成器函数中用来返回值。
使用生成器对象的元素时,不可以将其根据需要转化为列表或者元组。
与列表推导式不同的是,生成器推导式的结果是一个生成器对象,而不是列表,也不是元组。
从形式上看,生成器推导式与列表推导式非常接近,只是生成器推导式使用圆括号而不是列表推导式所使用的方括号。
1 1 2 3 5 8
1 1 2 2 3 3
8 5 3 2 1 1
1 2 3 4 5 6
list1 = ['red'; 'blue'; 'yellow']
list2 = [red, blue, yellow]
list3 = ['red', 'blue', 'yellow']
list4 = ['red'、 'blue'、'yellow']
del fruits['orange']
del fruits[1]
del fruits[2]
del fruits[orange]
fruits.insert('grape')
fruits.append('grape')
fruits.index('grape')
fruits.count('grape')
print(sunlight[1:n])
print(sunlight[1:n-1])
print(sunlight[::-1])
print(sunlight[:-1])
stationery.set("ink")
stationery.insert("ink")
stationery.pop("ink")
stationery.add("ink")
copy()
intersection()
union()
update()
('aa', 2) 4
('dd', 6) 4
('bb', 2) 3
('dd', 6) 3
数学
94
99
语文
有如下Python程序段:
for i in range(1,11): for j in range(1,11,2): if i j!=10: break print(i,j)
执行程序后,输出的结果为?
3 7
5 5
7 3
9 1
15
26
40
55
"Hello" "Python"
"HelloPython"
Hello Python
"Hello Python"
""
"otPo"
"otPol"
"hy l"
a[2] a[1] a[0]
a[::-1]
a[-1] a[-2] a[-3]
a[-1:0:-1]
print('我叫%s,今年我%d岁了'%(age,name))
print(‘我叫%s,今年我%d岁了'%(name,age)
print('我叫{},今年我{}岁了'.format(name,age))
print(f'我叫{name},今年我{age}岁了')
num=int(random.random()*99) 1
num=int(random.uniform(1,100))
num=random.randint(1,100)
num=random.choice(range(1,101))
s=math.pi*math.pow(r,2)
s=math.pi*r**2
s=math.pi*r*r
s=pi*r*r
整形
实型
字符串类型
列表类型
分词
数据可视化
计算
画图
发表评论 取消回复