当前位置:网站首页>实例050:随机数
实例050:随机数
2022-08-10 22:20:00 【懒笑翻】
题目:输出一个随机数。
程序分析:使用 random 模块。
# random.uniform(a, b) # 返回a, b之间的随机浮点数, 若a <= b则范围[a, b], 若a >= b则范围[b, a], a和b可以是实数。 # random.randint(a, b) # 返回a,b之间的整数,范围[a,b],注意:传入参数必须是整数,a一定要比b小。
代码:
import random
print(random.uniform(-10, -2))
结果:
边栏推荐
猜你喜欢
瑞幸咖啡第二季营收33亿:门店达7195家 更换CFO
The Thread State,
CFdiv2-Common Number-(奇偶数二分+规律)
Distribution Network Expansion Planning: Consider Decisions Using Probabilistic Energy Production and Consumption Profiles (Matlab Code Implementation)
测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
谁是边缘计算服务的采购者?是这六个关键角色
如何成为一名正义黑客?你应该学习什么?
Leave a message with a prize | OpenBMB x Tsinghua University NLP: The update of the large model open class is complete!
How to translate financial annual report, why choose a professional translation company?
Conditional Statements of Shell Programming (2)
随机推荐
RK3399 platform development series explanation (kernel-driven peripherals) 6.35, IAM20680 gyroscope introduction
This visual tool artifact is more intuitive and easy to use!love so much
Power system power flow calculation (Newton-Raphson method, Gauss-Seidel method, fast decoupling method) (Matlab code implementation)
威纶通触摸屏如何在报警的同时,显示出异常数据的当前值?
How to be a Righteous Hacker?What should you study?
LeetCode Daily 2 Questions 02: Reverse the words in a string (1200 each)
The perfect alternative to domestic Gravatar avatars Cravatar
OneNote 教程,如何在 OneNote 中整理笔记本?
学会开会|成为有连接感组织的重要技能
常用代码扩展点设计方式
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
分享一个后台管理系统可拖拽式组件的设计思路
JS学习 2022080
边缘与云计算:哪种解决方案更适合您的连接设备?
How does the Weiluntong touch screen display the current value of abnormal data while alarming?
STL-stack
Redis
Qualcomm Platform Development Series Explanation (Application) Introduction to QCMAP Application Framework
Conditional Statements of Shell Programming (2)
阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展