上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 50 下一页
摘要: 知识点: sort函数的排序规则key的使用 代码: dit1=dict(eval(input())) dit2=dict(eval(input())) for i,j in dit1.items(): dit2[i]=dit2.get(i,0)+j ans=list(dit2.items()) a 阅读全文
posted @ 2022-05-30 11:27 kingwzun 阅读(168) 评论(0) 推荐(0)
摘要: 知识点:sorted函数(dict默认10比2小) n=int(input()) num=[int(x) for x in input().split()] mp={} for i in num: mp.setdefault(i,0) mp[i]=mp[i]+1 for i,j in sorted( 阅读全文
posted @ 2022-05-30 10:48 kingwzun 阅读(56) 评论(0) 推荐(0)
摘要: 知识点: 使用eval函数 a=input() x=input() b=input() c=a+x+b if(int(b)==0 and x=="/"): print("divided by zero") else: print("{:.2f}".format(eval(c))) ``` 阅读全文
posted @ 2022-05-30 10:40 kingwzun 阅读(81) 评论(0) 推荐(0)
摘要: 解1: 使用dist n=input() mp={} for i in n: mp.setdefault(i,0) mp[i]=mp[i]+1 k=input() print(mp[k]) 解2: 使用count函数 n = input() k = input() print(n.count(k)) 阅读全文
posted @ 2022-05-30 10:33 kingwzun 阅读(127) 评论(0) 推荐(0)
摘要: n=int(input()) num=0 sum=0 for i in range(n): dic=eval(input()) for j in dic: temp=dic[j] num+=len(temp) for key in temp: sum+=temp[key] # print(" ") 阅读全文
posted @ 2022-05-30 10:14 kingwzun 阅读(153) 评论(0) 推荐(0)
摘要: 法1: a = input() b = input() sum = 0 for i in set(a): if i in set(b): sum += 1 print(sum) 法2:使用dict 正确代码; a=input() b=input() mp1={} mp2={} for i in a: 阅读全文
posted @ 2022-05-30 09:50 kingwzun 阅读(536) 评论(0) 推荐(0)
摘要: 这里的“X”是大写 mp = {} for i in range(3, 11): mp[i] = chr(48 + 12 - i) mp[0] = "1" mp[1] = "0" mp[2] = "X" judge = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10 阅读全文
posted @ 2022-05-30 09:12 kingwzun 阅读(62) 评论(0) 推荐(0)
摘要: n=int(input()) num=[int(x) for x in input().split()] for i in range(n): print(" ".join(map(str,num))) t=num[-1] num.pop() num.insert(0,t) 阅读全文
posted @ 2022-05-29 22:13 kingwzun 阅读(42) 评论(0) 推荐(0)
摘要: 莫名其妙 输入时input().split()错误 改为 t= [int(x) for x in input().split()]正确 a,b=map(int,input().split()) num=[] for i in range(a): t= [int(x) for x in input() 阅读全文
posted @ 2022-05-29 22:07 kingwzun 阅读(238) 评论(0) 推荐(0)
摘要: 知识点 sort函数的参数 (reverse=True) 代码 n=int(input()) num=[] for i in range(n): a,b,c=map(int,input().split()) t=a+b+c num.append(t) num.sort(reverse=True) f 阅读全文
posted @ 2022-05-29 21:55 kingwzun 阅读(160) 评论(0) 推荐(0)
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 50 下一页