随机生成100内的10个整数。
时间: 2024-05-09 07:16:49 浏览: 46
好的,我可以帮你生成随机的100以内的10个整数。以下是示例代码:
```python
import random
numbers = random.sample(range(1, 101), 10)
print(numbers)
```
输出类似如下结果:
```
[34, 87, 12, 56, 2, 69, 41, 49, 94, 17]
```
相关问题
python随机生成100内的10整数
可以使用Python的random模块中的randint函数来生成10个100以内的随机整数。代码如下:
```python
import random
random_list = []
for i in range(10):
random_list.append(random.randint(1, 100))
print(random_list)
```
输出结果为:
```
[56, 23, 99, 87, 12, 45, 34, 78, 91, 7]
```
随机生成100内的10整数python
可以使用Python中的random模块来生成随机整数,代码如下:
```python
import random
# 生成10个随机整数
for i in range(10):
num = random.randint(1, 100) # 生成1到100之间的随机整数
print(num)
```
输出结果为:
```
23
56
89
12
45
78
34
67
90
10
```
阅读全文
相关推荐












