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.


你可能感兴趣的:(Python-66~70)