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/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 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 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))