From 172ebc1bcd4b2e04204cc105ce033b21350c38a6 Mon Sep 17 00:00:00 2001 From: bhavya132 <2019uce0056@iitjammu.ac.in> Date: Sun, 13 Oct 2019 23:27:58 +0530 Subject: [PATCH 1/9] Mean,Median and Mode --- math.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 math.py diff --git a/math.py b/math.py new file mode 100644 index 0000000..d66ad79 --- /dev/null +++ b/math.py @@ -0,0 +1,36 @@ + +a=[1,2,3,4] +i=0 +a.sort() +l=len(a) +s=0 +i=0 +while(i=maxi): + maxi=count + r=a[i] + i=i+1 +print("median=",median) +print("mode",r) +print("mean:",mean) From 9bbfae1acb0331e6c63070fc6657cc4d61d9aec8 Mon Sep 17 00:00:00 2001 From: bhavya132 <2019uce0056@iitjammu.ac.in> Date: Sun, 13 Oct 2019 23:48:34 +0530 Subject: [PATCH 2/9] Characters with same frequency --- frequency.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 frequency.py diff --git a/frequency.py b/frequency.py new file mode 100644 index 0000000..b2ad346 --- /dev/null +++ b/frequency.py @@ -0,0 +1,14 @@ +s=input() +b=[] +for i in range(len(s)): + c=s[i] + count=0 + for j in range(len(s)): + if (c==s[j]): + count=count+1 + if(count not in b): + b.append(count) +if(len(b)==1): + print("all unique characters have same frequency") +else: + print("all unique characters don't have same frequency") From 2467414406eb6320912e688ed9c88c3c94c32842 Mon Sep 17 00:00:00 2001 From: bhavya132 <2019uce0056@iitjammu.ac.in> Date: Sun, 13 Oct 2019 23:56:11 +0530 Subject: [PATCH 3/9] count pairs in list --- pairs.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pairs.py diff --git a/pairs.py b/pairs.py new file mode 100644 index 0000000..fe55140 --- /dev/null +++ b/pairs.py @@ -0,0 +1,23 @@ +#count no of pairs of elements in a given list whose sum is equal to given sum +x=input().split(' ') +n=int(x[0]) #no of elements of list +s=int(x[1]) #required sum +count=0 +b=[] +a=input().split(' ') +for i in range(n): + f=0 + for j in range(n): + if(int(a[i])+int(a[j])==s): + f=1 + p=a[i] + q=a[j] + break + if(f==1): + if(p not in b and q not in b): + b.append(p) + b.append(q) + count=count+1 +print(count) #no of pairs + + From 741a03b880be073cc38abd1f3b03ec4a0a4f1f0d Mon Sep 17 00:00:00 2001 From: bhavya132 <2019uce0056@iitjammu.ac.in> Date: Mon, 14 Oct 2019 00:04:17 +0530 Subject: [PATCH 4/9] HCF and LCM using euclid's theorem --- euclid.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 euclid.py diff --git a/euclid.py b/euclid.py new file mode 100644 index 0000000..7815f18 --- /dev/null +++ b/euclid.py @@ -0,0 +1,22 @@ +#eucid alogarithm +#hcf and lcm +a=int(input("enter 1st no")) +b=int(input("enter 2nd no")) +hcf=1 +r=1 +if(a>b): + while(r>0): + r=a%b + a=b + b=r + hcf=a +else: + while(r>0): + r=b%a + b=a + a=r + hcf=b +print(hcf) +lcm=(a*b)//hcf +print(lcm) + From a08c00f944fd6a342b15fa4773f39458baeb6435 Mon Sep 17 00:00:00 2001 From: bhavya132 <2019uce0056@iitjammu.ac.in> Date: Mon, 14 Oct 2019 00:12:06 +0530 Subject: [PATCH 5/9] Palindrome, Perfect, and Prime no --- number.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 number.py diff --git a/number.py b/number.py new file mode 100644 index 0000000..38f8b81 --- /dev/null +++ b/number.py @@ -0,0 +1,37 @@ + +a=input("enter string") +#Palindrome +b='' +i=len(a)-1 +while(i>=0): + b=b+a[i] + i=i-1 +if(b==a): + print("palindrome") +else: + print("not palindrome") + +#Prime +n=int(a) +f=0 +i=2 +while i<=n**0.5: + if(n%i==0): + f=1 + break + i=i+1 +if(f==0): + print("Prime No") +else: + print("Not prime no") + +#Perfect no +n=int(a) +s=0 +for i in range(1,n): + if(n%i==0): + s=s+i +if(s==n): + print("Perfect no") +else: + print("not perfect no") From 883b1793eed167c4e7523d4751c85973873a7a06 Mon Sep 17 00:00:00 2001 From: bhavya132 <56509816+bhavya132@users.noreply.github.com> Date: Mon, 14 Oct 2019 00:31:10 +0530 Subject: [PATCH 6/9] Delete math.py --- math.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 math.py diff --git a/math.py b/math.py deleted file mode 100644 index d66ad79..0000000 --- a/math.py +++ /dev/null @@ -1,36 +0,0 @@ - -a=[1,2,3,4] -i=0 -a.sort() -l=len(a) -s=0 -i=0 -while(i=maxi): - maxi=count - r=a[i] - i=i+1 -print("median=",median) -print("mode",r) -print("mean:",mean) From cc4bbe97ea887e35604c6d3746baea34d120842e Mon Sep 17 00:00:00 2001 From: bhavya132 <56509816+bhavya132@users.noreply.github.com> Date: Mon, 14 Oct 2019 00:31:29 +0530 Subject: [PATCH 7/9] Delete number.py --- number.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 number.py diff --git a/number.py b/number.py deleted file mode 100644 index 38f8b81..0000000 --- a/number.py +++ /dev/null @@ -1,37 +0,0 @@ - -a=input("enter string") -#Palindrome -b='' -i=len(a)-1 -while(i>=0): - b=b+a[i] - i=i-1 -if(b==a): - print("palindrome") -else: - print("not palindrome") - -#Prime -n=int(a) -f=0 -i=2 -while i<=n**0.5: - if(n%i==0): - f=1 - break - i=i+1 -if(f==0): - print("Prime No") -else: - print("Not prime no") - -#Perfect no -n=int(a) -s=0 -for i in range(1,n): - if(n%i==0): - s=s+i -if(s==n): - print("Perfect no") -else: - print("not perfect no") From fa38e8d98fde7d06d6c42ee186b00ff9d2e7d9af Mon Sep 17 00:00:00 2001 From: bhavya132 <56509816+bhavya132@users.noreply.github.com> Date: Mon, 14 Oct 2019 00:31:52 +0530 Subject: [PATCH 8/9] Delete frequency.py --- frequency.py | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 frequency.py diff --git a/frequency.py b/frequency.py deleted file mode 100644 index b2ad346..0000000 --- a/frequency.py +++ /dev/null @@ -1,14 +0,0 @@ -s=input() -b=[] -for i in range(len(s)): - c=s[i] - count=0 - for j in range(len(s)): - if (c==s[j]): - count=count+1 - if(count not in b): - b.append(count) -if(len(b)==1): - print("all unique characters have same frequency") -else: - print("all unique characters don't have same frequency") From 967e5f59b235acb1f346a95cfb79745e364a02ff Mon Sep 17 00:00:00 2001 From: bhavya132 <56509816+bhavya132@users.noreply.github.com> Date: Mon, 14 Oct 2019 00:32:27 +0530 Subject: [PATCH 9/9] Delete euclid.py --- euclid.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 euclid.py diff --git a/euclid.py b/euclid.py deleted file mode 100644 index 7815f18..0000000 --- a/euclid.py +++ /dev/null @@ -1,22 +0,0 @@ -#eucid alogarithm -#hcf and lcm -a=int(input("enter 1st no")) -b=int(input("enter 2nd no")) -hcf=1 -r=1 -if(a>b): - while(r>0): - r=a%b - a=b - b=r - hcf=a -else: - while(r>0): - r=b%a - b=a - a=r - hcf=b -print(hcf) -lcm=(a*b)//hcf -print(lcm) -