如何能生成20个1到100之间的随机数。显示每个数字的系数。不要在Python中使用嵌套循环 [关闭] 。

问题描述 投票:-1回答:1

enter image description here

enter image description here

这里是我要显示输出的图像,完全是这样的。

python random numbers nested-loops factors
1个回答
0
投票

如果你不能使用嵌套循环,那么你可以使用单循环。

这是伪代码,不是python。

repeat 20 times
  pick a random number in [1, 100]
  find the factors of the number you just picked
  print or store the number and its factors
end repeat

你要尽力去编写这些代码 如果你有问题,那么给我们看你的代码,我们会帮助你。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.