当前位置:网站首页>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 ')
边栏推荐
- SecureCRT password to cancel session recording
- Advanced API (character stream & net for beginners)
- Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
- 【最詳細】最新最全Redis面試大全(50道)
- Advanced API (multithreading 02)
- 不出网上线CS的各种姿势
- [cmake] cmake link SQLite Library
- Pat grade a real problem 1166
- twenty million two hundred and twenty thousand three hundred and nineteen
- Advanced API (batch image Download & socket dialog)
猜你喜欢
随机推荐
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
Longest common prefix and
LeetCode
C code production YUV420 planar format file
Use of other streams
4279. 笛卡尔树
Hello world of vertx
Leetcode 213: 打家劫舍 II
Advanced APL (realize group chat room)
[cmake] cmake link SQLite Library
树莓派更新工具链
Use of file class
4279. Cartesian tree
OSI knowledge sorting
Raspberry pie update tool chain
[solved] unknown error 1146
Vertx restful style web router
Topic | synchronous asynchronous
691. 立方体IV
VMware network mode - bridge, host only, NAT network








