-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
Python Basic ++/Count Numbers in list for histogram. py.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
''' | ||
A counter turns a sequence of values into a defaultdict(int)-like object mapping keys to counts. we will use | ||
it to create Histogram | ||
''' | ||
from collections import Counter | ||
document = (10, | ||
1, | ||
10, | ||
5, | ||
7, | ||
4, | ||
1, | ||
1, | ||
10, | ||
10, | ||
9, | ||
10, | ||
1, | ||
3, | ||
9, | ||
9, | ||
4, | ||
1, | ||
8, | ||
6, | ||
7, | ||
3, | ||
6, | ||
7, | ||
3, | ||
10, | ||
5, | ||
3, | ||
10, | ||
4, | ||
6, | ||
8, | ||
10, | ||
5, | ||
5, | ||
9, | ||
10, | ||
8, | ||
10, | ||
9, | ||
10, | ||
10, | ||
8, | ||
7, | ||
7, | ||
10, | ||
8, | ||
6, | ||
4, | ||
6, | ||
1, | ||
9, | ||
10, | ||
2, | ||
3, | ||
3, | ||
9, | ||
2, | ||
3, | ||
8, | ||
1, | ||
7, | ||
3, | ||
10, | ||
6, | ||
6, | ||
9, | ||
6, | ||
7, | ||
9) | ||
word_counts = Counter(document) | ||
for word, count in word_counts.most_common(10): | ||
print('The Number %d Comes %d times ' %(word,count)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import random | ||
from collections import Counter | ||
|
||
#Take User Input for lower and Upper Range For auto Genrare 100 Number | ||
lower_range = int(input('Enter Lower Rnge : ' )) | ||
upper_range = int(input('Enter Upper Range : ' )) | ||
|
||
#Create a empty List to Append Random Number to List | ||
list0 = [] | ||
|
||
#create a random list to Lower range to Upper range | ||
for i in range(100): | ||
x = random.randint(lower_range, upper_range) | ||
list0.append(x) | ||
|
||
#count the NUmber most common 5 | ||
word_counts = Counter(list0) | ||
for word, count in word_counts.most_common(5): | ||
print('The Number %d Comes %d times ' %(word,count)) |