当前位置:网站首页>Random function usage notes
Random function usage notes
2022-07-05 07:47:00 【Fall in love with wx】
1. Import random modular
import random
2. Generate (n, m) Random integer between
>>> import random
>>> a = random.randint(1, 10) #1<=a<=10 And n,m Size must be n<m
>>> print(a)
3
>>>
3. take 0-1 Between random floating-point numbers
>>> import random
>>> a = random.random()
>>> print(a)
0.7513964072198035 # Default 15-16 digit
>>>
4. Generate (n, m) Is a random floating point number
>>> import random
>>> a = random.uniform(1, 3)
>>> print(a)
1.750766501474142
>>> a = random.uniform(3, 1) #n,m The size can be reversed
>>> print(a)
2.067256580652267
>>>
5. Generate (n, m) Is a random floating point number , The decimal point is x position
>>> import random
>>> a = random.uniform(1, 10)
>>> b = round(a, 2) #x=2
>>> print(b)
4.55
>>>
To be updated …
边栏推荐
- Opendrive arc drawing script
- MySQL - storage engine
- msys2
- RTOS in the development of STM32 single chip microcomputer
- [idea] common shortcut keys
- What is Bezier curve? How to draw third-order Bezier curve with canvas?
- Embedded AI intelligent technology liquid particle counter
- Scm-05 basis of independent keyboard
- C language uses arrays to realize the intersection, union, difference and complement of sets
- Threads and processes
猜你喜欢
Close of office 365 reading
How to modify the file path of Jupiter notebook under miniconda
Latex notes
Line test -- data analysis -- FB -- teacher Gao Zhao
Thunderbird tutorial \ easy to use mail client
MySQL blind note common functions
[neo4j] common operations of neo4j cypher and py2neo
Practical application cases of digital Twins - fans
With the help of Navicat for MySQL software, the data of a database table in different or the same database link is copied to another database table
Package ‘*****‘ has no installation candidate
随机推荐
611. Number of effective triangles
msys2
Global and Chinese market of peeled bourdon tubes 2022-2028: Research Report on technology, participants, trends, market size and share
IC software learning
editplus
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
Significance and requirements of semiconductor particle control
Opendrive arc drawing script
Global and Chinese market of plastic recycling machines 2022-2028: Research Report on technology, participants, trends, market size and share
MySql——存储引擎
Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
Numpy——1. Creation of array
Apple script
A series of problems in offline installation of automated test environment (ride)
Summary of STM32 serial port sending and receiving data methods
Global and Chinese market for blood typing 2022-2028: Research Report on technology, participants, trends, market size and share
Anaconda pyhton multi version switching
Global and Chinese markets of nano biosensors 2022-2028: Research Report on technology, participants, trends, market size and share
Differences between pycharm and idle and process -- join() in vs Code
Logistic regression: the most basic neural network