From 3348df81f38c7905d0c78c1233f90377a21323e2 Mon Sep 17 00:00:00 2001 From: Bani39 <163390231+Bani39@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:33:37 +0530 Subject: [PATCH 1/3] Add files via upload --- Task/Banishree sharma/ques1.py | 26 +++++++++++++++++++++++ Task/Banishree sharma/ques2.py | 38 ++++++++++++++++++++++++++++++++++ Task/Banishree sharma/ques6.py | 31 +++++++++++++++++++++++++++ Task/Banishree sharma/ques7.py | 19 +++++++++++++++++ Task/Banishree sharma/ques8.py | 17 +++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 Task/Banishree sharma/ques1.py create mode 100644 Task/Banishree sharma/ques2.py create mode 100644 Task/Banishree sharma/ques6.py create mode 100644 Task/Banishree sharma/ques7.py create mode 100644 Task/Banishree sharma/ques8.py diff --git a/Task/Banishree sharma/ques1.py b/Task/Banishree sharma/ques1.py new file mode 100644 index 0000000..8fc5449 --- /dev/null +++ b/Task/Banishree sharma/ques1.py @@ -0,0 +1,26 @@ +s = input("Enter a string(s) : ") +t = input("Enter a string(t) : ") +l1 = len(s) +l2 = len(t) +flag = 0 +print("Length of s ",l1) +print("Length of t ",l2) +if(l1==l2): + for i in range(97,123): + c1=0 + c2=0 + for j in s: + if j==chr(i): + c1=c1+1 + for k in t: + if k==chr(i): + c2=c2+1 + if c1!=c2: + flag=1 + break + if flag==0: + print("Anagram") + else: + print("Not Anagram") +else: + print("Not Anagram") \ No newline at end of file diff --git a/Task/Banishree sharma/ques2.py b/Task/Banishree sharma/ques2.py new file mode 100644 index 0000000..5be7cfd --- /dev/null +++ b/Task/Banishree sharma/ques2.py @@ -0,0 +1,38 @@ +class CharOccur: + def __init__(self, character, occurrence): + + self.character = character + self.occurrence = occurrence + +def frequency(s: str): + if not s: + print("Empty string") + return + + occurrences = [] + + for c in s: + found = False + for occur in occurrences: + + if occur.character == c: + occur.occurrence += 1 + found = True + break + if not found: + occurrences.append(CharOccur(c, 1)) + + # Printing the character - occurrences pair + for occur in occurrences: + print(occur.character, occur.occurrence) + + +s1 = "GFG" +print("For " + s1) +frequency(s1) + +s2 = "aaabccccffgfghc" +print("For " + s2) +frequency(s2) + + diff --git a/Task/Banishree sharma/ques6.py b/Task/Banishree sharma/ques6.py new file mode 100644 index 0000000..b96bad1 --- /dev/null +++ b/Task/Banishree sharma/ques6.py @@ -0,0 +1,31 @@ +def is_prime(n): + if n <= 1: + return False + if n == 2: + return True + if n % 2 == 0: + return False + for i in range(3, int(n**0.5) + 1, 2): + if n % i == 0: + return False + return True + +N = int(input("Enter the number of points in the array : ")) +A = [] +for i in range(0, N): + ele = int(input("Enter the element : ")) + A.append(ele) + +sp = 0 +lp = 0 +for i in A: + if is_prime(i): + if i < sp: + sp = i + if i > lp: + lp = i + +if sp is None or lp is None: + print("1") +else: + print(abs(lp - sp)) \ No newline at end of file diff --git a/Task/Banishree sharma/ques7.py b/Task/Banishree sharma/ques7.py new file mode 100644 index 0000000..9166693 --- /dev/null +++ b/Task/Banishree sharma/ques7.py @@ -0,0 +1,19 @@ +primefactor=[] +mrp=int(input("Enter An Amount:-")) + +for i in range (2,mrp+1): + if mrp%i==0: + f=0 + for j in range(2,i): + if i%j==0: + f=1 + break + if f==0: + primefactor.append(i) + +print(primefactor) +a=primefactor[0] +alfi=a +roy=mrp-a +print(alfi) +print(roy) \ No newline at end of file diff --git a/Task/Banishree sharma/ques8.py b/Task/Banishree sharma/ques8.py new file mode 100644 index 0000000..d8b0a6c --- /dev/null +++ b/Task/Banishree sharma/ques8.py @@ -0,0 +1,17 @@ +a=int(input("enter the no of element:")) +li=[] +for i in range (0,a): + ele=input("enter the element:") + li.append(ele) +print(li) +key=[] +for i in range(0,a): + ele=li[i] + key.append(ele) +print(key) +value=[] +for i in range(0,a): + k=li.count(li[i]) + value.append(k) +d={i:j for (i,j) in zip(key,value)} +print("the dictionary is:",d) \ No newline at end of file From 65da8a8f5eb0f9d9e3352d94ab27250a3b6bf6b3 Mon Sep 17 00:00:00 2001 From: Bani39 <163390231+Bani39@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:42:30 +0530 Subject: [PATCH 2/3] Update ques2.py --- Task/Banishree sharma/ques2.py | 37 ---------------------------------- 1 file changed, 37 deletions(-) diff --git a/Task/Banishree sharma/ques2.py b/Task/Banishree sharma/ques2.py index 5be7cfd..d3f5a12 100644 --- a/Task/Banishree sharma/ques2.py +++ b/Task/Banishree sharma/ques2.py @@ -1,38 +1 @@ -class CharOccur: - def __init__(self, character, occurrence): - - self.character = character - self.occurrence = occurrence - -def frequency(s: str): - if not s: - print("Empty string") - return - - occurrences = [] - - for c in s: - found = False - for occur in occurrences: - - if occur.character == c: - occur.occurrence += 1 - found = True - break - if not found: - occurrences.append(CharOccur(c, 1)) - - # Printing the character - occurrences pair - for occur in occurrences: - print(occur.character, occur.occurrence) - - -s1 = "GFG" -print("For " + s1) -frequency(s1) - -s2 = "aaabccccffgfghc" -print("For " + s2) -frequency(s2) - From 724c2ec412c8a1e061d46a50f7a884cf3ac14762 Mon Sep 17 00:00:00 2001 From: Bani39 <163390231+Bani39@users.noreply.github.com> Date: Sun, 16 Jun 2024 13:43:09 +0530 Subject: [PATCH 3/3] Add files via upload --- Task/Banishree sharma/ques3.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Task/Banishree sharma/ques3.py diff --git a/Task/Banishree sharma/ques3.py b/Task/Banishree sharma/ques3.py new file mode 100644 index 0000000..35b6afb --- /dev/null +++ b/Task/Banishree sharma/ques3.py @@ -0,0 +1,13 @@ +num=(input("Enter an integer: ")) +a=[] +for i in num: + a.append(i) +print("The input list is ", a) +b=0 +for i in a: + b=(b*10)+int(i) +c=b+1 +d=[] +for i in str(c): + d.append(i) +print("The final list is ", d) \ No newline at end of file