当前位置:网站首页>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 ')
边栏推荐
- Distributed transactions
- 2. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
- Advanced API (byte stream & buffer stream)
- Leetcode 198: 打家劫舍
- 【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
- Arduino Serial系列函数 有关print read 的总结
- 2021-07-18
- II. D3.js draw a simple figure -- circle
- 论文学习——鄱阳湖星子站水位时间序列相似度研究
- Common analysis with criteria method
猜你喜欢

Interview questions about producers and consumers (important)

Common problems in io streams

Recursion, Fibonacci sequence

c语言指针的概念

4279. Cartesian tree

Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS

1. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log

Basic knowledge about SQL database

Final, override, polymorphism, abstraction, interface

VMWare网络模式-桥接,Host-Only,NAT网络
随机推荐
FileInputStream and fileoutputstream
SQL create temporary table
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Advanced API (batch image Download & socket dialog)
Hash table, generic
Advanced API (byte stream & buffer stream)
Spa single page application
4279. 笛卡尔树
Arduino 软串口通信 的几点体会
[solved] unknown error 1146
为什么说数据服务化是下一代数据中台的方向?
带你全流程,全方位的了解属于测试的软件事故
【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5
C code production YUV420 planar format file
Longest common prefix and
Various postures of CS without online line
Map interface and method
在 4EVERLAND 上存储 WordPress 媒体内容,完成去中心化存储
Dora (discover offer request recognition) process of obtaining IP address