From 0598ce956c480ba6fe1d05464fe6b774d1bf75af Mon Sep 17 00:00:00 2001 From: jeevaarul Date: Thu, 31 Jan 2019 15:08:48 +0530 Subject: [PATCH 1/3] array qustions --- 4.x more x.py | 12 ++++++++++++ 5.x more count.py | 12 ++++++++++++ countarray.py | 11 +++++++++++ findxval.py | 10 ++++++++++ lengtn.py | 7 +++++++ 5 files changed, 52 insertions(+) create mode 100644 4.x more x.py create mode 100644 5.x more count.py create mode 100644 countarray.py create mode 100644 findxval.py create mode 100644 lengtn.py diff --git a/4.x more x.py b/4.x more x.py new file mode 100644 index 0000000..15f5363 --- /dev/null +++ b/4.x more x.py @@ -0,0 +1,12 @@ +def more_then_once(array,x): + flag=False + count=0 + for i in array: + if i==x: + count+=1 + if count>1: + flag=True + return flag +array=[1,2,3,5,5,6,7,8] +x=input("enter the value:") +print(more_then_once(array,x)) diff --git a/5.x more count.py b/5.x more count.py new file mode 100644 index 0000000..48725bf --- /dev/null +++ b/5.x more count.py @@ -0,0 +1,12 @@ +def more_then_once_count(array,x): + + count=0 + for i in array: + if i==x: + count+=1 + + + return count +array=[1,2,3,5,5,5,5,5,6,7,8] +x=input("enter the value:") +print(more_then_once_count(array,x)) diff --git a/countarray.py b/countarray.py new file mode 100644 index 0000000..f6c5619 --- /dev/null +++ b/countarray.py @@ -0,0 +1,11 @@ + +def countarray(a): + count=0 + + while(a>0): + temp=a%10 + count+=1 + a=a//10 + return count +a=(1234) +print(countarray(a)) diff --git a/findxval.py b/findxval.py new file mode 100644 index 0000000..e501da6 --- /dev/null +++ b/findxval.py @@ -0,0 +1,10 @@ +def findx(array): + flag=False + for i in array: + if(i==x): + flag=True + return flag +array=[1,3,5,7,9] +x=input("enter the value:") +print(findx(array)) + diff --git a/lengtn.py b/lengtn.py new file mode 100644 index 0000000..d721e66 --- /dev/null +++ b/lengtn.py @@ -0,0 +1,7 @@ +def arrlen(array): + count=0 + for i in array: + count+=1 + return count +array=[123,485,345] +print(arrlen(array)) From 6804bdb92225311dc75af001cc2787c7365781ef Mon Sep 17 00:00:00 2001 From: jeevaarul Date: Thu, 31 Jan 2019 15:32:36 +0530 Subject: [PATCH 2/3] sum unsorted array --- 6.sumarray.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 6.sumarray.py diff --git a/6.sumarray.py b/6.sumarray.py new file mode 100644 index 0000000..e6fee25 --- /dev/null +++ b/6.sumarray.py @@ -0,0 +1,8 @@ +def sumarray(a): + sum=0 + for i in a: + sum+=i + + return sum +a=[4,5,7,3,1] +print(sumarray(a)) \ No newline at end of file From fe4da615555582acd55150464410832add371868 Mon Sep 17 00:00:00 2001 From: jeevaarul Date: Sat, 2 Feb 2019 11:08:47 +0530 Subject: [PATCH 3/3] program order name --- 7.sumarray.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 7.sumarray.py diff --git a/7.sumarray.py b/7.sumarray.py new file mode 100644 index 0000000..e6fee25 --- /dev/null +++ b/7.sumarray.py @@ -0,0 +1,8 @@ +def sumarray(a): + sum=0 + for i in a: + sum+=i + + return sum +a=[4,5,7,3,1] +print(sumarray(a)) \ No newline at end of file