Python-66~70

---66---

Question:

>Please write a program which accepts basic mathematic expression from console and print the evaluation result.

Example:

>If the following n is given as input to the program:     35 + 3

>Then, the output of the program should be:     38

Hints:

>Use eval() to evaluate an expression

Solution:


---67---

Question:

>Please write a binary search function which searches an item in a sorted list. The function should return the index of element to be searched in the list.

Hints:

>Use if/elif to deal with conditions.

Solution:

没理解这题。主要涉及二分搜索树的知识,没看懂,哭了。。。


---68---

Question:

>Please generate a random float where the value is between 10 and 100 using Python module.

Solution:


---69---

Question:

>Please generate a random float where the value is between 5 and 95 using Python module.

Solution:


---70---

Question:

>Please write a program to output a random even number between 0 and 10 inclusive using random module and list comprehension.

Hints:

>Use random.choice() to a random element from a list.


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Lua 5.1 参考手册 by Roberto Ierusalimschy, Luiz Henrique de F...
    苏黎九歌阅读 13,907评论 0 38
  • Awesome Ruby Toolbox Awesome A collection of awesome Ruby...
    debbbbie阅读 2,934评论 0 3
  • 推荐指数: 6.0 书籍主旨关键词:特权、焦点、注意力、语言联想、情景联想 观点: 1.统计学现在叫数据分析,社会...
    Jenaral阅读 5,752评论 0 5
  • 昨天,在回家的路上,坐在车里悠哉悠哉地看着三毛的《撒哈拉沙漠的故事》,我被里面的内容深深吸引住了,尽管上学时...
    夜阑晓语阅读 3,831评论 2 9
  • 一月四号的大沙有个想法。从昨晚到现在就一直围绕在脑子里。或许深受那些小说的影响,或许真的就是我自己脑子或者精神么有...
    一個人的大沙阅读 4,087评论 3 4