From 71bd068eeef60c9849a8d93c231a007b5836ae87 Mon Sep 17 00:00:00 2001 From: Deepak Raj <54245038+perfect104@users.noreply.github.com> Date: Thu, 28 Nov 2019 14:08:08 +0530 Subject: [PATCH] intial commit intial commit --- Control Flow/Enumerate_2.py | 2 +- ...Matplotlib codes in Jupyter notebook.ipynb | 14 ++-- ...Count Numbers in list for histogram. py.py | 78 +++++++++++++++++++ .../Create random Number and Count Number.py | 19 +++++ 4 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 Python Basic ++/Count Numbers in list for histogram. py.py create mode 100644 Python Basic ++/Create random Number and Count Number.py diff --git a/Control Flow/Enumerate_2.py b/Control Flow/Enumerate_2.py index 02b429d..f6043c4 100644 --- a/Control Flow/Enumerate_2.py +++ b/Control Flow/Enumerate_2.py @@ -14,5 +14,5 @@ x = [5 ,7, 10, 12, 15, 20] y = [3 ,5, 4, 10, 10, 19] for x , y in zip(x,y): - print('{} is greater than {}'.format(x,y)) + print('%s is greater than %s' %(x,y)) diff --git a/MatplotLib/Matplotlib codes in Jupyter notebook.ipynb b/MatplotLib/Matplotlib codes in Jupyter notebook.ipynb index 9a62c5b..edaf26f 100644 --- a/MatplotLib/Matplotlib codes in Jupyter notebook.ipynb +++ b/MatplotLib/Matplotlib codes in Jupyter notebook.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 4, "metadata": { "scrolled": true }, @@ -64,7 +64,7 @@ "" ] }, - "execution_count": 13, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" }, @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -128,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -159,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -200,7 +200,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 8, "metadata": {}, "outputs": [ { diff --git a/Python Basic ++/Count Numbers in list for histogram. py.py b/Python Basic ++/Count Numbers in list for histogram. py.py new file mode 100644 index 0000000..8eecd0c --- /dev/null +++ b/Python Basic ++/Count Numbers in list for histogram. py.py @@ -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)) \ No newline at end of file diff --git a/Python Basic ++/Create random Number and Count Number.py b/Python Basic ++/Create random Number and Count Number.py new file mode 100644 index 0000000..5919aff --- /dev/null +++ b/Python Basic ++/Create random Number and Count Number.py @@ -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))