Python测试题10道(含答案)

这是一篇包含10道Python编程题目的博客,涵盖了变量输出、字典操作、列表操作等内容。每道题目都有详细答案,适合Python初学者巩固基础知识。更多练习题目可通过二维码获取。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 以下代码的输出结果为:

print(round(-3.6))

A.-4 B.-4.0 C.-3 D. -3.0

2 以下代码的输出结果为(Python3.6及以上):

dic={
 'a':1,'b':4,'c':9,'xy':13}
print(dic.popitem())

A.(‘a’:1,‘b’:4,‘c’:9)

B.(‘c’:9,‘xy’:13)

C.(‘a’,13)

D.(‘xy’,13)

3 以下代码的输出结果为:

adict = dict.fromkeys(['key1', 'key2'], [])
adict['key1'].append(123)
adict['key1'] = 456
print(adict['key2'])

A.报错 B.[] C.[123] D. 456

4 以下代码的输出结果为:

print([1, 2] == [(1), (2)])
print([1, 2] == [(1,), (2,)])

A.True True B.True False C.False True D.False False

5 以下代码的输出结果为:

print('hi') if 3 > 4 else print('bye')

A.报错 B.hi C.bye D.hi bye

6 以下代码的输出结果为:

num = 6 if True == 1.0 else 8
print(num)

A.报错 B.6 C.8 D.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值