帮我写一个程序,从1-58里随机抽三个数字
时间: 2023-12-03 10:44:33 浏览: 35
好的,以下是 Python 代码实现:
```python
import random
# 生成1-58的数字列表
numbers = list(range(1, 59))
# 随机抽三个数字
result = random.sample(numbers, 3)
# 输出结果
print(result)
```
运行结果可能如下:
```
[23, 49, 8]
```
相关问题
用java语言帮我写一个程序:从1-58中随机抽三个数字
好的,以下是Java代码实现:
```java
import java.util.Random;
public class Main {
public static void main(String[] args) {
Random random = new Random();
int num1 = random.nextInt(58) + 1;
int num2 = random.nextInt(58) + 1;
int num3 = random.nextInt(58) + 1;
System.out.printf("随机抽取的三个数字为:%d、%d、%d", num1, num2, num3);
}
}
```
运行结果类似于:
```
随机抽取的三个数字为:23、7、51
```
以上程序中,我们使用了Java内置的`Random`类来生成随机数,并且通过`nextInt()`方法指定了范围为1-58。最后输出随机抽取的三个数字即可。
帮我写一个列表表示从1-70
当然,这很简单。以下是从1到70的列表:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]。
还有其他的问题吗?
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)