FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm-python2/random_list.py at master · yangjun616/algorithm-python2 · GitHub
yangjun616
algorithm-python2
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm-python2
/
random_list.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (16 loc) · 562 Bytes
Breadcrumbs
algorithm-python2
/
random_list.py
Copy path
File metadata and controls
20 lines (16 loc) · 562 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
#coding:utf-8
"""
问题
要求定义一个int型数组a,包含100个元素,保存100个随机的4位数。再定义一个
int型数组b,包含10个元素。统计a数组中的元素对10求余等于0的个数,保存
到b[0]中;对10求余等于1的个数,保存到b[1]中,……依此类推。
"""
import
random
if
__name__
==
"__main__"
:
a
=
[
random
.
randint
(
1000
,
9999
)
for
i
in
range
(
101
)]
a_remainder
=
[
i
%
10
for
i
in
a
]
b
=
[
a_remainder
.
count
(
i
)
for
i
in
range
(
10
)]
print
a
print
a_remainder
print
b
Back
|
FazBrowse Home
|
New Git URL