1:https://www.lanqiao.cn/problems/497/learning/
取整函数(遗忘)https://blog.csdn.net/u010087338/article/details/121598961
另外format格式控制能够避免结果省略0的问题。
第一次错误:输出顺序问题
mark = [] peopleNumber = int(input()) markTotal = 0 for i in range (peopleNumber): markInput = int(input()) markTotal += markInput mark.append(markInput) mark.sort() print(mark[0]) print(mark[peopleNumber-1]) # a = round(markTotal/peopleNumber,2) # print(a) print("{:.2f}".format(markTotal/peopleNumber))
mark = [] peopleNumber = int(input()) markTotal = 0 for i in range (peopleNumber): markInput = int(input()) markTotal += markInput mark.append(markInput) mark.sort() print(mark[peopleNumber-1]) print(mark[0]) # a = round(markTotal/peopleNumber,2) # print(a) print("{:.2f}".format(markTotal/peopleNumber))
2.https://www.lanqiao.cn/problems/819/learning/
暴力拆解,主要是逻辑问题。
python中not、and、or的优先级与详细用法:
https://blog.csdn.net/m0_51284422/article/details/109441190
import os import sys answer = 0 data = ["VLPWJVVNNZSWFGHSFRBCOIJTPYNEURPIGKQGPSXUGNELGRVZAG",\ "SDLLOVGRTWEYZKKXNKIRWGZWXWRHKXFASATDWZAPZRNHTNNGQF",\ "ZGUGXVQDQAEAHOQEADMWWXFBXECKAVIGPTKTTQFWSWPKRPSMGA",\ "BDGMGYHAOPPRRHKYZCMFZEDELCALTBSWNTAODXYVHQNDASUFRL",\ "YVYWQZUTEPFSFXLTZBMBQETXGXFUEBHGMJKBPNIHMYOELYZIKH",\ "ZYZHSLTCGNANNXTUJGBYKUOJMGOGRDPKEUGVHNZJZHDUNRERBU",\ "XFPTZKTPVQPJEMBHNTUBSMIYEGXNWQSBZMHMDRZZMJPZQTCWLR",\ "ZNXOKBITTPSHEXWHZXFLWEMPZTBVNKNYSHCIQRIKQHFRAYWOPG",\ "MHJKFYYBQSDPOVJICWWGGCOZSBGLSOXOFDAADZYEOBKDDTMQPA",\ "VIDPIGELBYMEVQLASLQRUKMXSEWGHRSFVXOMHSJWWXHIBCGVIF",\ "GWRFRFLHAMYWYZOIQODBIHHRIIM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(50): for x in range(30): for y in range(50): if (((i==x and y>j) or (x>i and y==j) or(abs(x-i)==abs(y-j))) and (not(x<=i and y<=j))and (data[x][y]>data[i][j])): answer += 1 print(answer)
3.https://www.lanqiao.cn/problems/254/learning/
a,b=map(int, input().split()) print(a+b)
主要是map方法,实现映射。
4.https://www.lanqiao.cn/problems/646/learning/
数论。。。
找素数方法:
import os import sys import math # 请在此输入您的代码 num = [2] for i in range(2,2090): # 搜索素数 for j in range(2,int(math.sqrt(i)+1)): # 或者{for j in range(2, i):} if i % j == 0: break else: #得让i%j==0将j在[2,i)中判断完才能说明i是素数 num.append(i) for i in range(2,200): #先找到首相 for j in range(200,220): #找到公差 a = 0 for k in range(i+j,i+11*j,j): #将找到的首相和公差进行判断,如果其中的每一项都满足条件,则找到公差 if k in num : a+=1 if a==9: print(j)
标签:markTotal,https,22,peopleNumber,mark,range,2022,print From: https://www.cnblogs.com/MrMKG/p/16612628.html