From 93f32afc22f524c6ac2469238ebe9261ec6eb444 Mon Sep 17 00:00:00 2001 From: anjali142 Date: Fri, 25 Oct 2019 16:26:35 +0530 Subject: [PATCH 1/4] perfect --- perfect.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 perfect.py diff --git a/perfect.py b/perfect.py new file mode 100644 index 0000000..1fd22ca --- /dev/null +++ b/perfect.py @@ -0,0 +1,11 @@ +# Python Program to find Perfect Number using For loop + +Number = int(input(" Please Enter any Number: ")) +Sum = 0 +for i in range(1, Number): + if(Number % i == 0): + Sum = Sum + i +if (Sum == Number): + print(" %d is a Perfect Number" %Number) +else: + print(" %d is not a Perfect Number" %Number) \ No newline at end of file From 5634756059ce1614bf5e69faf7dc56b3f5069273 Mon Sep 17 00:00:00 2001 From: anjali142 Date: Fri, 25 Oct 2019 16:32:09 +0530 Subject: [PATCH 2/4] special_number --- special_twodigit.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 special_twodigit.py diff --git a/special_twodigit.py b/special_twodigit.py new file mode 100644 index 0000000..7616181 --- /dev/null +++ b/special_twodigit.py @@ -0,0 +1,22 @@ +def specialNumber(n): + + # Checking whether entered + # number is 2 digit or not + if (n < 10 or n > 99): + print("Invalid Input! Number", + " should have 2 digits only") + else: + first = n // 10 + last = n % 10 + sum = first + last + pro = first * last + if ((sum + pro) == n): + print(n ," is a Special ", + "Two-Digit Number") + else: + print(n , " is Not a ", + "Special Two-Digit Number") + +# Driver code +n = 59 +specialNumber(n) \ No newline at end of file From 5d6410e36f241137775d86cda749c2391bbd7188 Mon Sep 17 00:00:00 2001 From: anjali142 Date: Fri, 25 Oct 2019 16:38:19 +0530 Subject: [PATCH 3/4] strong_number --- strong.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 strong.py diff --git a/strong.py b/strong.py new file mode 100644 index 0000000..a13a778 --- /dev/null +++ b/strong.py @@ -0,0 +1,16 @@ +sum1=0 +num=int(input("Enter a number:")) +temp=num +while(num): + i=1 + f=1 + r=num%10 + while(i<=r): + f=f*i + i=i+1 + sum1=sum1+f + num=num//10 +if(sum1==temp): + print("The number is a strong number") +else: + print("The number is not a strong number") \ No newline at end of file From 4a31d9b0919d6f624ca534d6401172b89dd24617 Mon Sep 17 00:00:00 2001 From: Anjali Deep <45489595+anjali142@users.noreply.github.com> Date: Mon, 28 Oct 2019 10:06:34 +0530 Subject: [PATCH 4/4] binary search in python --- binarysearch.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 binarysearch.py diff --git a/binarysearch.py b/binarysearch.py new file mode 100644 index 0000000..c28240e --- /dev/null +++ b/binarysearch.py @@ -0,0 +1,21 @@ +def binarySearch (arr, l, r, x): + if r >= l: + mid = l + (r - l)/2 + if arr[mid] == x: + return mid + elif arr[mid] > x: + return binarySearch(arr, l, mid-1, x) + else: + return binarySearch(arr, mid + 1, r, x) + else: + return -1 +arr = [ 2, 3, 4, 10, 40 ] +x = 10 + +# Function call +result = binarySearch(arr, 0, len(arr)-1, x) + +if result != -1: + print "Element is present at index % d" % result +else: + print "Element is not present in array"