Python-71~75

---71---

Question:

>Please write a program to output a random number, which is divisible by 5 and 7, between 10 and 150 inclusive using random module and list comprehension.

Hints:

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

Solution:


----72---

Question:

>Please write a program to generate a list with 5 random numbers between 100 and 200 inclusive.

Hints:

>Use random.sample() to generate a list of random values.

Solution:


---73---

Question:

>Please write a program to randomly generate a list with 5 even numbers between 100 and 200 inclusive.

Solution:

解法一

解法二


---74---

Question:

>Please write a program to randomly generate a list with 5 numbers, which are divisible by 5 and 7 , between 1 and 1000 inclusive.

Solution:


---75---

Question:

>Please write a program to randomly print a integer number between 7 and 15 inclusive.

Hints:

>Use random.randrange() to a random integer in a given range.

Solution:

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容