http://bbs.fishc.com/thread-93788-1-1.html 鱼C论坛上相关Python练习题

Given an unsorted array of integers, find the smallest number in the array, the largest number in the array, and the smallest number between the two array bounds that is not in the array.

For instance, given the array [-1, 4, 5, -23, 24], the smallest number is -23, the largest number is 24, and the smallest number between the array bounds is -22. You may assume the input is well-formed.

You solution should return an array [smallest, minimumAbsent, largest]

The smallest integer should be the integer from the array with the lowest value.

The largest integer should be the integer from the array with the highest value.

The minimumAbsent is the smallest number between the largest and the smallest number that is not in the array.

  1. minMinMax([-1, 4, 5, -23, 24]); //[-23, -22, 24]
  2. minMinMax([1, 3, -3, -2, 8, -1]); //[-3, 0, 8]
  3. minMinMax([2, -4, 8, -5, 9, 7]); //[-5, -3,9]

复制代码

以下是我写的代码:

# -*- coding: utf-8 -*-
l = [2, -4, 8, -5, 9, 7]
L1 = sorted(l)
L2 = []
L2.append(L1[0])
a = L1[0]
for i in L1:
    if i == a:
        a = a+1
    else:
        L2.append(a)
        break
L2.append(L1[-1])
print L2

运行结果:

鱼C论坛上Python练习题-72相关推荐

  1. 鱼c论坛python课后题-【零基础】Python3学习课后练习题(十九)

    本文是跟着鱼C论坛小甲鱼零基础学习Python3的视频学习的,课后题也是跟随每一课所附属的题目来做的,根据自己的理解和标准答案记录的笔记. 第二十一课 测试题: 0.请使用lambda表达式将下边函数 ...

  2. 鱼c论坛 python课后题_【零基础】Python3学习课后练习题(二)

    本文是跟着鱼C论坛小甲鱼零基础学习Python3的视频学习的,课后题也是跟随每一课所附属的题目来做的,根据自己的理解和标准答案记录的笔记. 第二课 测试题: 0.什么是 BIF ? 答:BIF == ...

  3. 零基础学习python(鱼C论坛)

    我和python的第一次亲密接触课后习题 Python 是什么类型的语言? Python是一门动态解释型的强类型定义语言. 我们先看看编译型,其实它和汇编语言是一样的:也是有一个负责翻译的程序来对我们 ...

  4. 小甲鱼python课后题百度网盘_[全套55讲] 鱼c论坛小甲鱼python课后题

    [全套55讲] 鱼c论坛小甲鱼python课后题 第 1 课0. Python 是什么类型的语言Python 是脚本语言脚本语言Scripting language是电脑编程语言,因此也能让开发者藉以 ...

  5. 鱼c论坛 python课后题pdf,我与python的第一次亲密接触_课后测试题及答案.pdf

    我与python的第一次亲密接触_课后测试题及答案.pdf 还剩 10页未读, 继续阅读 下载文档到电脑,马上远离加班熬夜! 亲,喜欢就下载吧,价低环保! 内容要点: 2015/8/19 第001讲: ...

  6. python编程工资-看到抖音上Python工程师晒得工资条,我沉默了......

    原标题:看到抖音上Python工程师晒得工资条,我沉默了...... 我是个抖音中毒者 闲来无事就喜欢刷抖音 最近刷到了一个Python工程师的工资条 然后我默默的打开看了 然后就默默的关闭了 如今P ...

  7. python编程输入标准-Python练习题,,T1.编写程序,输入

    Python练习题,,T1.编写程序,输入 T1.编写程序,输入一个自然数字符串,然后输出各位数字之和. a=input("输入一串数字:") b=0 for i in a: b= ...

  8. Python打印杨辉三角形 RUNOOB python练习题61

    用来练手的python练习题,原题链接: python练习实例61 题干: 打印出杨辉三角形 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 ...

  9. RUNOOB python练习题44

    用来练手的python练习题,原题链接:python练习实例44 题干: 两个 3 行 3 列的矩阵,实现其对应位置的数据相加,并返回一个新矩阵 使用基本的List类写起来就比较麻烦,需要初始化一个3 ...

最新文章

  1. 微信小程序学习做动画效果
  2. JavaScript服务器端开发基础之Math对象小结
  3. Merge into 详细介绍
  4. HDU4000Fruit Ninja【树状数组+组合数】
  5. Flask-sqlalchemy外键关系映射
  6. 让创新触手可及,阿里云容器服务 ACK 发行版开放免费下载
  7. Ubuntu shutdown 关机、重启、注销 命令 常用实例
  8. tcp_nodelay memcached java_TCP_NODELAY 和 TCP_NOPUSH
  9. cannot resolve symbol spark
  10. Excel催化剂开源第37波-音视频文件元数据提取(分辨率,时长,采样率等)
  11. android 日期相,Android日历始终保持相同的日期
  12. 中科大 计算机网络7 分组延迟 分组丢失 吞吐量
  13. 连接查询_左连接/右连接/全连接的区别
  14. 软件测试岗需要会什么条件,应聘软件测试岗位需要具备什么条件?
  15. predict函数 R_RROC三剑客(一)使用R语言手撕ROC曲线
  16. 【LeetCode】81. Search in Rotated Sorted Array II (2 solutions)
  17. php 将汉字转为拼音,PHP汉字转换为拼音字头原理
  18. 基于双流融合网络的遥感图像融合 论文笔记
  19. laravel Migration与Seeder的用法
  20. html5谷歌地图,谷歌地图API和HTML 5

热门文章

  1. matlab可以画3d图吗,如何用matlab画3d图
  2. 开源DMS - 文档管理系统 - logicaldoc 里面转换SWF
  3. Unity | 如何使用webm透明视频
  4. OpenStack Networking网络
  5. 【项目管理案例】第十期:如何做好项目采购管理
  6. UrlEncode编码
  7. 浅聊OpenHarmony
  8. 微信开发者工具报错Debugging connection was closed. Reason:Render process gone.Reconnect when ready by reopeni
  9. 工作之余享受一下天籁之音(千千静听音效插件)
  10. javascript工具类函数