Python 作业题求助......

2016-09-21 21:33:18 +08:00
 craiiz
Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter the numbers 4,5,6,7 and Match the desired output as shown below:

Invalid input
Maximum is 7
Minimum is 4

please build your program based on the sample code:

largest = None
smallest = None
while True:
num = raw_input("Enter a number: ")
if num == "done" : break
print num

print "Maximum", largest
5164 次点击
所在节点    Python
29 条回复
bwangel
2016-09-22 17:39:07 +08:00
@wemore ,闲着没事去翻译文档!

就打开 Python 文档,调一个感兴趣的库,然后一句一句翻译,用来写个博客啥的。慢慢对于英文你就麻木了!
vagary
2016-09-22 17:47:00 +08:00
有个妹子朋友出国读书,不是计算机专业,但是要 修几门基础编程。
于是那段时间 天天给她写作业。
估计楼主可能也是这样的情况。
fengfisher
2016-09-22 17:49:03 +08:00
@zhanglintc 不过比在百度知道上提问似乎要好一点, 毕竟还知道 V2EX...+1
wemore
2016-09-22 18:09:57 +08:00
@bwangel 目前正在看 spring 的官方文档,有道从未离手(ಥ_ಥ)
yexiaoxing
2016-09-23 01:24:41 +08:00
歪个楼,嘛,这题目看起来像我们 Python 入门课第一节课的作业 :)
maple
2016-09-23 09:25:38 +08:00
干嘛不去 stackflow.奇怪....
wizardforcel
2016-09-24 11:42:52 +08:00
@firebroo 这种作业不用考虑什么输入校验,除非题目里有明确要求。

有安全意识是好事,但要分场合使用。

@msg7086 飞机的速度序列是无穷序列,这道题中的程序必须输入个‘ done ’才能出结果,显然不能统计。
firebroo
2016-09-24 14:54:04 +08:00
@wizardforcel 安全编码是需要习惯思维培养。
msg7086
2016-09-25 07:49:07 +08:00
@wizardforcel 飞机是会停的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/307955

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX