程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python] learning notes week12-0 list

編輯:Python

Title Description

Programming , The elements indexed by even bits in the list ( The inclusion index is 0 The elements of ) Sort in ascending order , And put the sorted results back into the original list . Write the procedure as a function , The parameters are list .

Input

Use input() Function input list .

Output

Output the sorted list

The sample input

[2,3,8,1,5,0,3,9]

Sample output

[2, 3, 3, 1, 5, 0, 8, 9]

a=eval(input())
a[::2] = sorted(a[::2])
print(a)

Title Description

Enter a list of integers a, And enter an integer x, Delete all values in the list as x Number of numbers , Then output the list

Input

The first line is the input list In the second line, enter the integer to delete

Output

Output the deleted list

The sample input

5,3,8,98,3,87,3,3,2 3

Sample output

[5, 8, 98, 87, 2]

a=list(map(eval,input().split(",")))
b=eval(input())
c=[]
for i in range(0,len(a)):
if a[i]!=b:
c.append(a[i])
print(c)

【PYTHON】 The referee scored # list

Title Description

In gymnastics , The judges rate the contestants . The rule of scoring is to remove the highest score and the lowest score , Then calculate the average score , Please program the score of a player .

Input

The first 1 Line contains an integer n (2<n<100), The number of judges , The first 2 Line inclusion n It's an integer , Express n The scores of the judges . Each integer is separated by a space .

Output

Output player's score , The result is reserved 2 Decimal place .

The sample input

4 100 99 98 97

Sample output

98.50

a=eval(input())
b=list(map(eval,input().split(" ")))
b.sort()
print("{:.2f}".format(sum(b[1:-1])/(a-2)))

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved