当前位置:网站首页>List exercises after class
List exercises after class
2022-07-03 07:26:00 【GAVL】
DAY05 List exercises
1、 A set of achievements 67,90,-20,105,88,92, Please change the negative score to 0, exceed 100 Of is set to 100, Then the output .
# 1、 A set of achievements 67,90,-20,105,88,92, Please change the negative score to 0, exceed 100 Of is set to 100, Then the output .
from typing import List
lst = [67, 90, -20, 105, 88, 92]
for i in range(len(lst)):
if lst[i]<0:
lst[i]=0
elif lst[i]>100:
lst[i]=100
print(lst)
2、 Input 5 Results of students , Descending output , And find the average score
# 2、 Input 5 Results of students , Descending output , And find the average score
a = (input(" Please enter the scores of five students :"))
a1 = a.split(',')
lst1 = list(a1)
print(lst1)
lst1.sort(reverse=True)
print(lst1)
print(len(lst1))
sum = 0
for i in range(0, len(lst1)):
sum += int(lst1[i])
print(" Average score :" + str(sum / len(lst1)))
--------------------------------------
lst2=[]
for i in range(5):
score=int(input(" Please enter the grade :"))
lst2.append(score)
sum+=score
lst2.sort(reverse=True)
print(lst2)
print(f' The average is {
sum/5}')
3、 Determine whether a sequence is orderly
lst3 = [12, 12,12,12,12]
if lst3==sorted(lst3):
print(' yes ')
elif lst3==sorted(lst3,reverse=False):
print(' yes ')
else:
print(' no ')
边栏推荐
- TypeScript let与var的区别
- VMWare网络模式-桥接,Host-Only,NAT网络
- Why is data service the direction of the next generation data center?
- 【最详细】最新最全Redis面试大全(50道)
- FileInputStream and fileoutputstream
- Raspberry pie update tool chain
- Jeecg menu path display problem
- Distributed ID
- 带你全流程,全方位的了解属于测试的软件事故
- Specified interval inversion in the linked list
猜你喜欢

Pat grade a real problem 1166

C代码生产YUV420 planar格式文件

TCP cumulative acknowledgement and window value update

【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘

File operation serialization recursive copy

IP home online query platform

《指環王:力量之戒》新劇照 力量之戒鑄造者亮相

Deep learning parameter initialization (I) Xavier initialization with code

Circuit, packet and message exchange

IPv4 address
随机推荐
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
691. 立方体IV
691. Cube IV
Vertx's responsive MySQL template
4279. Cartesian tree
Basic knowledge about SQL database
Split small interface
Jeecg data button permission settings
Common operations of JSP
C code production YUV420 planar format file
Unified handling and interception of exception exceptions of vertx
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
IPv4 address
Book recommendation~
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
VMware network mode - bridge, host only, NAT network
Distributed transactions
High concurrency memory pool
Wireshark software usage
Understanding of class