- 博客(6)
- 收藏
- 关注
原创 python复习题 字典与合集
1. 【单选题】 下述代码的运行结果是()。dict={'1':6,'2':5}theCopy=dictdict['1']=4sum=dict['1']+theCopy['1']print(sum)A. 8B. 12C. 10D. 9正确答案:A2. 【单选题】 下述代码的运行结果是 ( ) 。x={1:2}x[2]=3print(x)A. {1: 2, 2: 3}B. {1: 3, 2: 3}C. {1: 3}D. {1: 2: 3}
2021-06-16 13:31:26
1314
原创 python复习题 函数
1. 【单选题】下列定义函数的方法,在Python中正确的是()。1分A. class 函数名(类型 形参1, 类型 形参2,…)B. function 函数名(形参1, 形参2,…)C. def 函数名(形参1, 形参2,…)D. def 函数名(类型 形参1, 类型 形参2,…)正确答案:C2. 【单选题】 下述代码的运行结果是( )。list(map( lambda x:len(x), ['ab123','a','12'] ) )A. [5, 1, 2]B. [3,
2021-06-16 13:29:41
4042
原创 【python】字典处理
已知字符串s="When in the course of human events,it becomes necessary for one people to dissolve the political bands which have connected them with another,and to assume among the Powers of the earth,the separate and equal station to which the Laws of Nature and
2021-06-16 13:27:27
1609
【python】输入一个正整数,若正整数的各个位的值是偶数,则变为偶数的一半;奇数,则变为奇数的三倍。输出变化后的列表。将列表的前半部分降序排列,将列表的后半部分升序排列并输出。
n=int(input("请输入一个正整数:"))lst=list(str(n))#print(lst)lst1=[]for x in lst:if int(x)%2==0:lst1.append(int(x)//2)else:lst1.append(int(x)*3)print("数值变化后的列表为:")print(lst1)lst2=lst1[:len(lst1)//2]lst3=lst1[len(lst1)...
2021-06-16 13:25:42
1514
【python】输入一个正整数,判断整数的各位数字是否互不相同
n=int(input("请输入一个正整数:"))if len(str(n))==len(set(str(n))):print(n,"的个位数字互不相同")else:print(n,"中有重复数字")
2021-06-16 13:24:29
5580
原创 python复习题 文件
1. 【单选题】 下列代码的输出结果是:()a=10b=0try:c=a/bprint(c)except ZeroDivisionError as e:print(e)finally:print("always excute")print("done")A.division by zerodoneB.division by zeroalways excuteC.division by zeroalways excutedoneD.division by ze...
2021-06-16 13:18:40
3570
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅