当前位置:网站首页>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 …
边栏推荐
- Use go language to read TXT file and write it into Excel
- 1089 insert or merge, including test point 5
- Global and Chinese markets for waste treatment air switches 2022-2028: Research Report on technology, participants, trends, market size and share
- About the problem that MySQL connector net cannot be cleared in MySQL
- Linked list (establishment, deletion, insertion and printing of one-way linked list)
- NSIS search folder
- Threads and processes
- Altium Designer 19.1.18 - 更改铺铜的透明度
- [professional literacy] core conferences and periodicals in the field of integrated circuits
- Temperature sensor DS18B20 principle, with STM32 routine code
猜你喜欢
II Simple NSIS installation package
The mutual realization of C L stack and queue in I
Idea common settings
Leetcode solution - number of islands
Butterfly theme beautification - Page frosted glass effect
Software designer: 03 database system
Scm-05 basis of independent keyboard
CADD course learning (6) -- obtain the existing virtual compound library (drugbank, zinc)
High end electronic chips help upgrade traditional oil particle monitoring
Thunderbird tutorial \ easy to use mail client
随机推荐
Altium designer 19.1.18 - clear information generated by measuring distance
Day09 how to create packages import package naming conventions Alibaba Development Manual
QT's excellent articles
The folder directly enters CMD mode, with the same folder location
Count and sort the occurrence times of specific fields through SQL statements
Pit record of Chmod 2 options in deepin
Temperature sensor DS18B20 principle, with STM32 routine code
Mouse click fireworks explosion effect
assert_ Usage of param function
QT excellent articles
1089 Insert or Merge 含测试点5
Cygwin installation
Cadence learning records
Apple animation optimization
NSIS search folder
Using C language to realize IIC driver in STM32 development
Butterfly theme beautification - Page frosted glass effect
Latex notes
MySQL blind note common functions
Differences between pycharm and idle and process -- join() in vs Code