当前位置:网站首页>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的区别
- Common operations of JSP
- pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
- PgSQL converts string to double type (to_number())
- [cmake] cmake link SQLite Library
- 4279. 笛卡尔树
- 专题 | 同步 异步
- [plus de détails] dernière entrevue complète redis (50)
- Industrial resilience
- Hisat2 - stringtie - deseq2 pipeline for bulk RNA seq
猜你喜欢
4279. 笛卡尔树
7.2 brush two questions
Common methods of file class
【已解决】Unknown error 1146
Common problems in io streams
Summary of Arduino serial functions related to print read
[solved] unknown error 1146
High concurrency memory pool
Store WordPress media content on 4everland to complete decentralized storage
《指环王:力量之戒》新剧照 力量之戒铸造者亮相
随机推荐
Summary of Arduino serial functions related to print read
Qtip2 solves the problem of too many texts
Store WordPress media content on 4everland to complete decentralized storage
7.2 brush two questions
[solved] win10 cannot find a solution to the local group policy editor
Advanced API (serialization & deserialization)
PgSQL converts string to double type (to_number())
Recursion, Fibonacci sequence
Thoughts on project development
Take you through the whole process and comprehensively understand the software accidents that belong to testing
【最詳細】最新最全Redis面試大全(50道)
691. Cube IV
Advanced APL (realize group chat room)
C代码生产YUV420 planar格式文件
Interview questions about producers and consumers (important)
Le Seigneur des anneaux: l'anneau du pouvoir
IP home online query platform
c语言指针的概念
4279. 笛卡尔树
Longest common prefix and