当前位置:网站首页>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 ')
边栏推荐
- 691. Cube IV
- Book recommendation~
- Warehouse database fields_ Summary of SQL problems in kingbase8 migration of Jincang database
- 3311. 最长算术
- Split small interface
- GStreamer ffmpeg avdec decoded data flow analysis
- Take you through the whole process and comprehensively understand the software accidents that belong to testing
- Understanding of class
- Wireshark software usage
- Summary of Arduino serial functions related to print read
猜你喜欢

Summary of abnormal mechanism of interview

Interview questions about producers and consumers (important)

C代码生产YUV420 planar格式文件

Recursion, Fibonacci sequence

最全SQL与NoSQL优缺点对比

Topic | synchronous asynchronous

How long is the fastest time you can develop data API? One minute is enough for me

SecureCRT password to cancel session recording

4279. Cartesian tree

Specified interval inversion in the linked list
随机推荐
Basic components and intermediate components
LeetCode
Summary of abnormal mechanism of interview
Advanced API (use of file class)
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
Lombok cooperates with @slf4j and logback to realize logging
Advanced API (multithreading)
Spa single page application
OSI knowledge sorting
TreeMap
[set theory] order relation (partial order relation | partial order set | example of partial order set)
An overview of IfM Engage
How long is the fastest time you can develop data API? One minute is enough for me
4279. 笛卡尔树
twenty million two hundred and twenty thousand three hundred and nineteen
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
GStreamer ffmpeg avdec decoded data flow analysis
La différence entre le let Typescript et le Var
Advanced API (batch image Download & socket dialog)
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS