Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 532 Bytes

exercises.md

File metadata and controls

14 lines (13 loc) · 532 Bytes

习题 5.1 编写一个程序,重复读取数据,知道用户输入"done",一旦输入"done",就打印出总和,个数和平均数,如果用户输入的不是数字,使用try和except捕获异常,打印错误信息,然后跳过,继续执行循环。

Enter a number: 4
Enter a number: 5
Enter a number: bad data
Invalid input
Enter a number: 7
Enter a number: done
16 3 5.333333333333333

习题 5.2 编写一个程序,提示用户输入一组数字,然后输出最大值和最小值。