python 在随机数列中找第二大和第二小的数字
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/06 00:52:22
python 在随机数列中找第二大和第二小的数字
import random
def RandomList(length=10,low=-10,high=10):
RandomList=[]
for i in range(length):
RandomList.append(random.randint(low,high))
这是现在已有的.急
import random
def RandomList(length=10,low=-10,high=10):
RandomList=[]
for i in range(length):
RandomList.append(random.randint(low,high))
这是现在已有的.急
如果能用Python现成的函数的话 很简单我给你提示一下 剩下的应该很简单了
>>> import random
>>> def RandomList(length=10,low=-10,high=10):
... RandomList=[]
... for i in range(length):
... RandomList.append(random.randint(low,high))
... return RandomList
...
>>> list = RandomList
>>> list
<function RandomList at 0x00000000021F7F98>
>>> list = RandomList()
>>> list
[3, 10, -7, -4, 9, -1, 5, 6, 9, 3]
>>> list=sorted(list)
>>> list
[-7, -4, -1, 3, 3, 5, 6, 9, 9, 10]
>>> 升序排序完成之后 第二小的肯定就是 list[1]而第二大的就是 list[length-2]
>>> import random
>>> def RandomList(length=10,low=-10,high=10):
... RandomList=[]
... for i in range(length):
... RandomList.append(random.randint(low,high))
... return RandomList
...
>>> list = RandomList
>>> list
<function RandomList at 0x00000000021F7F98>
>>> list = RandomList()
>>> list
[3, 10, -7, -4, 9, -1, 5, 6, 9, 3]
>>> list=sorted(list)
>>> list
[-7, -4, -1, 3, 3, 5, 6, 9, 9, 10]
>>> 升序排序完成之后 第二小的肯定就是 list[1]而第二大的就是 list[length-2]
python 在随机数列中找第二大和第二小的数字
excel,求一个数列中数字第二大和第二小的公式
写一个python的script,要求生成1000个随机的[a,b,c]数列;a,b,c在0和1之间
excel中怎样把A1:A20中第一大,第二大和第三大的数字分别标在B20,C20,D20的表格中,
python括号区别python中,花括号,中括号,小括号的区别在哪里
第二大题的第二小题
第一大题的第二小题,第二大题的第二小题和第三小题.
第一大题第二小题和第二大题
在python 中is和= = 的区别
第二大题的第二小题和第三大题,
第二大题的第二小题和第三大题
第二大题和第三大题的第二小题怎么做?