From d383278035c7040ec36cadf989668d516164bf5d Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月19日 00:36:41 +0530 Subject: [PATCH 01/19] Create Task1.py --- Tasks/Task1.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Tasks/Task1.py diff --git a/Tasks/Task1.py b/Tasks/Task1.py new file mode 100644 index 0000000..d6ddf3e --- /dev/null +++ b/Tasks/Task1.py @@ -0,0 +1,7 @@ +str = input() + +for i in range(len(str)): + if i%2 == 0: + print(str[i], end="") + else: + print(ord(str[i]), end="") From c79327eeafa27e693019dada23a863c5a0ecc264 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月22日 23:43:30 +0530 Subject: [PATCH 02/19] Create Swapping.py --- Tasks/Swapping.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Tasks/Swapping.py diff --git a/Tasks/Swapping.py b/Tasks/Swapping.py new file mode 100644 index 0000000..861bf07 --- /dev/null +++ b/Tasks/Swapping.py @@ -0,0 +1,21 @@ +a=10 +b=20 +print(a,b) + +a,b=b,a +print(a,b) + +a=a+b +b=a-b +a=a-b +print(a,b) + +a^=b +b^=a +a^=b +print(a,b) + +a=a*b +b=a/b +a=a/b +print(a,b) # float value From 50e6bc4fd5b586237b7c5979a0f60ea848bf382b Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月23日 20:18:52 +0530 Subject: [PATCH 03/19] Python Training Python Task During College Training Periods. --- Training/AdamNumber.py | 22 ++++++++++++++++++++ Training/AmicablePair.py | 20 +++++++++++++++++++ Training/AstrologyNumber.py | 40 +++++++++++++++++++++++++++++++++++++ Training/PrimeDigit.py | 25 +++++++++++++++++++++++ Training/StrongNumber.py | 19 ++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 Training/AdamNumber.py create mode 100644 Training/AmicablePair.py create mode 100644 Training/AstrologyNumber.py create mode 100644 Training/PrimeDigit.py create mode 100644 Training/StrongNumber.py diff --git a/Training/AdamNumber.py b/Training/AdamNumber.py new file mode 100644 index 0000000..278bd83 --- /dev/null +++ b/Training/AdamNumber.py @@ -0,0 +1,22 @@ +''' + +Adams Number + +''' + +a=int(input()) +s1=a*a +b=0 +t=a +while t>0: + b=(b*10)+t%10; + t//=10 +t=b*b +s2=0 +while t>0: + s2=s2*10+t%10 + t//=10 +if(s1==s2): + print("Adam Number") +else: + print("Not Adam Number") diff --git a/Training/AmicablePair.py b/Training/AmicablePair.py new file mode 100644 index 0000000..88a1336 --- /dev/null +++ b/Training/AmicablePair.py @@ -0,0 +1,20 @@ +''' + +Amicable Pair + +''' + +a,b=map(int,input().split()) +s1=0 +s2=0 +for i in range(1,a): + if(a%i==0): + s1+=i +for i in range(1,b): + if(b%i==0): + s2+=i +if(a==s2 and b==s1): + print("Amicable Pair") +else: + print("Not Amicable Pair") + diff --git a/Training/AstrologyNumber.py b/Training/AstrologyNumber.py new file mode 100644 index 0000000..df0e20f --- /dev/null +++ b/Training/AstrologyNumber.py @@ -0,0 +1,40 @@ +''' + +Astrology Number + +''' + +# Method 1 +# n=int(input()) +# while(n//10!=0): +# t=n +# s=0 +# while t>0: +# s+=(t%10) +# t//=10 +# n=s +# print(n) + +""" Method 2 (refer) """ +n=int(input()) +if(n%9==0): + print("9") +else: + print(n%9) + +# Method 3 +# n=int(input()) +# s=0 +# while(n>9): +# s+=(n%9) +# n//=10 +# print(s) + + +# Method 4 +# n = int(input()) +# while n>= 10: +# n = sum(int(digit) for digit in str(n)) +# print(n) + + diff --git a/Training/PrimeDigit.py b/Training/PrimeDigit.py new file mode 100644 index 0000000..51b1ef8 --- /dev/null +++ b/Training/PrimeDigit.py @@ -0,0 +1,25 @@ +''' + +Prime digits in a number + +Eg-1: +123456 -> 2 3 5 + +Eg-2: +87546363 -> 7 5 3 3 + +''' + +n=input() +for i in range(len(n)): + f=0 + a=int(n[i]) + if(a==1): + continue + for j in range(2,a): + if a%j==0: + f=1; + break; + if f==0: + print(a,end=" ") + diff --git a/Training/StrongNumber.py b/Training/StrongNumber.py new file mode 100644 index 0000000..a4b1f2d --- /dev/null +++ b/Training/StrongNumber.py @@ -0,0 +1,19 @@ +''' + +Strong Number + +''' + +n=int(input()) +t=n +res=0 +while(t>0): + s=1 + for i in range(2,(t%10)+1): + s*=i + res+=s + t//=10 +if res==n: + print("Strong Number") +else: + print("Not Strong Number") From 5c3628363100db4fe7a751331a99dc2281d6c5fb Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月24日 20:39:51 +0530 Subject: [PATCH 04/19] Create Training.py --- Training/Training.py | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Training/Training.py diff --git a/Training/Training.py b/Training/Training.py new file mode 100644 index 0000000..e752562 --- /dev/null +++ b/Training/Training.py @@ -0,0 +1,55 @@ +''' + + Python Task + +''' + +# for i in range(5): +# print(i*"*") + +# n=int(input()) +# for i in range(1,n+1): +# for j in range(1,i+1): +# print(end="*") +# print() + + +# for i in range(1,6): +# for j in range(1,6): +# if(i==j or i+j==6): +# print("*",end="") +# else: +# print(" ",end="") +# print() + +# for i in range(5): +# for j in range(5): +# print((i+j)%2,end="") +# print() + +# Rombus +# for i in range(1,6): +# for j in range(1,6-i): +# print(" ",end="") +# for k in range(1,6): +# print("*",end="") +# print() + +#Traingle +# for i in range(1,6): +# for j in range(0,5-i): +# print(" ",end="") +# for j in range(0,2*i-1): +# print("*",end="") +# print() + +#Traingle Inverted +for i in range(6,0,-1): + for j in range(0,5-i+1): + print(" ",end="") + for j in range(0,2*i-1): + print("*",end="") + print() + + + From 509cabab9a232178600c70055d442b196c389336 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月24日 20:40:21 +0530 Subject: [PATCH 05/19] Create StarPattern.py --- Training/StarPattern.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Training/StarPattern.py diff --git a/Training/StarPattern.py b/Training/StarPattern.py new file mode 100644 index 0000000..f4b137d --- /dev/null +++ b/Training/StarPattern.py @@ -0,0 +1,41 @@ +''' + +Input: +water + +Output: +w w w + aaa +water + eee +r r r + +''' + +# s=input() +# n=len(s) +# k=0 +# for i in range(n): +# for j in range(n): +# if(i==n//2): +# for l in range(n): +# print(s[l],end=" ") +# break; +# if (j==n//2 or i==j or j==n-i-1): +# print(s[k],end=" ") +# else: +# print(" ",end=" ") +# k+=1 +# print() + +s=input() +n=len(s) +for i in range(n): + for j in range(n): + if(i==j or i+j==n-1 or n//2==j): + print(s[i],end=" ") + elif n//2==i: + print(s[j],end=" ") + else: + print(" ",end=" ") + print() From 689b76b020145b02f0266effd74d6332fb6a282e Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月25日 20:43:05 +0530 Subject: [PATCH 06/19] Day 5 Training Session --- Training/Anagram.py | 9 +++++++++ Training/HollowDiamond.py | 33 +++++++++++++++++++++++++++++++++ Training/Isogram.py | 17 +++++++++++++++++ Training/Panagram.py | 17 +++++++++++++++++ Training/UniqueCharacter.py | 19 +++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 Training/Anagram.py create mode 100644 Training/HollowDiamond.py create mode 100644 Training/Isogram.py create mode 100644 Training/Panagram.py create mode 100644 Training/UniqueCharacter.py diff --git a/Training/Anagram.py b/Training/Anagram.py new file mode 100644 index 0000000..1e24ced --- /dev/null +++ b/Training/Anagram.py @@ -0,0 +1,9 @@ +""" + + Anagram + +""" + +s=input() +a=input() +print(sorted(a)==sorted(s)) diff --git a/Training/HollowDiamond.py b/Training/HollowDiamond.py new file mode 100644 index 0000000..f8a9e22 --- /dev/null +++ b/Training/HollowDiamond.py @@ -0,0 +1,33 @@ +''' + + Hollow Diamond + +Input: 4 + +Output: + 1 + 2 2 + 3 3 +4 4 + 3 3 + 2 2 + 1 + +''' + +n=int(input()) + +for i in range(1,n+1): + for j in range(1,n+n+1): + if(j==n-i+1 or j==n+i-1): + print(i,end="") + else: + print(end=" ") + print() +for i in range(n-1,0,-1): + for j in range(1,n+n+1): + if(j==n-i+1 or j==n+i-1): + print(i,end="") + else: + print(end=" ") + print() diff --git a/Training/Isogram.py b/Training/Isogram.py new file mode 100644 index 0000000..9c2f6ab --- /dev/null +++ b/Training/Isogram.py @@ -0,0 +1,17 @@ +''' + + Isogram + +''' + +a=input() +char=[] +f=0 +for i in a: + if i in char: + f=1 + char.append(i) +if f==0: + print("Isogram") +else: + print("Not Isogram") diff --git a/Training/Panagram.py b/Training/Panagram.py new file mode 100644 index 0000000..5b7f5b5 --- /dev/null +++ b/Training/Panagram.py @@ -0,0 +1,17 @@ +''' + +Panagram + +''' + +a="abcdefghijklmnopqrstuvwxyz" +s=input().lower() +f=0 +for i in a: + if i not in s: + f=1 + break +if f==0 : + print("Panagram") +else: + print("Not Panagram") diff --git a/Training/UniqueCharacter.py b/Training/UniqueCharacter.py new file mode 100644 index 0000000..7f54e1d --- /dev/null +++ b/Training/UniqueCharacter.py @@ -0,0 +1,19 @@ +''' + +Unique Character of two string and print in ascending order + +''' + +a=input() +b=input() +s=set() +for i in a: + if i not in b: + s.add(i) + +for i in b: + if i not in a: + s.add(i) +s=list(s) +s=sorted(s) +print(s) From 009b2cc18911f1594e4035d7db1df4d034765341 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月26日 20:59:38 +0530 Subject: [PATCH 07/19] Create Except.py --- Except.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Except.py diff --git a/Except.py b/Except.py new file mode 100644 index 0000000..fcbbde7 --- /dev/null +++ b/Except.py @@ -0,0 +1,13 @@ +''' + + Exception Handling... + +''' + +try: + x=int(input()) + y=x/0 +except ZeroDivisionError: + print("Error: Division by Zero") +except ValueError: + print("Error: Invalid Input") From 5308a687a8394496c9fc8d293755e1bcacf385b1 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年8月28日 19:23:50 +0530 Subject: [PATCH 08/19] Add files via upload --- Training/Format.py | 14 ++++++++++++++ Training/HollowSqString.py | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Training/Format.py create mode 100644 Training/HollowSqString.py diff --git a/Training/Format.py b/Training/Format.py new file mode 100644 index 0000000..2de4145 --- /dev/null +++ b/Training/Format.py @@ -0,0 +1,14 @@ +''' + + Format Usage and implementation + +''' + +n=int(input()) +m=n/2 +print(format(n,".2f")) +print("{0} {1}".format(m,n)) +print("{1}".format(m,n)) + +print("{2}".format(m,n,15)) +print("{0} {2} {1}".format(m,n,15,8.5)) diff --git a/Training/HollowSqString.py b/Training/HollowSqString.py new file mode 100644 index 0000000..bd3c8ef --- /dev/null +++ b/Training/HollowSqString.py @@ -0,0 +1,18 @@ +s=input() +n=len(s) +for i in range(n): + for j in range(n): + if( i==0): + print(s[j],end=" ") + elif(j==0): + print(s[i],end=" ") + elif(j==n-1): + print(s[n-i-1],end=" ") + elif(i==n-1): + print(s[n-j-1],end=" ") + else: + print(" ",end=" ") + print() + + + From aafb7f4855b13c27e587243657ac3e9b23d9ade2 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: Fri, 1 Sep 2023 20:19:15 +0530 Subject: [PATCH 09/19] Create SwapCase.py --- Training/SwapCase.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Training/SwapCase.py diff --git a/Training/SwapCase.py b/Training/SwapCase.py new file mode 100644 index 0000000..5ab3687 --- /dev/null +++ b/Training/SwapCase.py @@ -0,0 +1,18 @@ +''' + + SwapCase character of the string + +''' + +s="" +a=input() +for j in range(len(a)): + i=a[j] + if(i>='a' and i<='z'): + s+=i.upper() + elif(i>='A' and i<='z'): + s+=i.lower() + else: + s+=i +print(s) + From 0118600bacedd8d9d53e7f8c1840b36240e62dc4 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: Sat, 2 Sep 2023 18:09:57 +0530 Subject: [PATCH 10/19] Daily Training --- Training/AlphaPattern.py | 27 +++++++++++++++++++ Training/NumberAsterisk.py | 46 +++++++++++++++++++++++++++++++++ Training/OperatorOverloading.py | 16 ++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 Training/AlphaPattern.py create mode 100644 Training/NumberAsterisk.py create mode 100644 Training/OperatorOverloading.py diff --git a/Training/AlphaPattern.py b/Training/AlphaPattern.py new file mode 100644 index 0000000..043e54c --- /dev/null +++ b/Training/AlphaPattern.py @@ -0,0 +1,27 @@ +n=5 +lower=97 +for i in range(1,n+1): + x=2*i-1 + for j in range(1,x+1): + if(j==1 or j==x): + print("*",end=" ") + else: + if(j<=x): + num=lower-32 + print(chr(num),end=" ") + lower+=1 + print() +m=n-1 +upper=num +for i in range(0,n): + y=2*m+1 + for j in range(1,y+1): + if(j==1 or j==y): + print("*",end=" ") + else: + if(j<=y): + num=upper+32 + print(chr(num),end=" ") + upper-=1 + m-=1 + print() diff --git a/Training/NumberAsterisk.py b/Training/NumberAsterisk.py new file mode 100644 index 0000000..cc6e5a6 --- /dev/null +++ b/Training/NumberAsterisk.py @@ -0,0 +1,46 @@ +''' + +Input: 5 + +Output: +* +* * +* 1 * +* 2 3 * +* 4 5 6 * +* 7 8 * +* 9 * +* * +* + +''' + + +n=5 +k=1 +for i in range(n+n): + if(i Date: Mon, 4 Sep 2023 22:53:20 +0530 Subject: [PATCH 11/19] Create LjustLambda.py --- Training/LjustLambda.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Training/LjustLambda.py diff --git a/Training/LjustLambda.py b/Training/LjustLambda.py new file mode 100644 index 0000000..9a08267 --- /dev/null +++ b/Training/LjustLambda.py @@ -0,0 +1,20 @@ +''' + + Usage of ljust Method and lambda + +''' + + +a="String" + +print(a.ljust(20)) +print(a.ljust(20,'0')) + +x = lambda : 10 +print(x()) + +x=lambda a,b: a+b +print(x(9,10)) + +# Represents the function +print(type(x)) From 08f927bf9407d8cab33eeddc105828fabae710c6 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:26:38 +0530 Subject: [PATCH 12/19] Create Corners.py --- Training/Corners.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Training/Corners.py diff --git a/Training/Corners.py b/Training/Corners.py new file mode 100644 index 0000000..b11271c --- /dev/null +++ b/Training/Corners.py @@ -0,0 +1,21 @@ +''' + +Input: +4 + +Ouput: +* * + + +* * + +''' + +n=int(input()) +for i in range(n): + for j in range(n): + if i==0 and j==0 or i==0 and j==n-1 or i==n-1 and j==0 or i==n-1 and j==n-1: + print("*",end="") + else: + print(" ",end="") + print() From 02f9982ea078dea7f1f477bde29f04c934136fa7 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:27:03 +0530 Subject: [PATCH 13/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 83fa432..072ca96 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# <-- My Repository for Learning Python Programming --> +# <--my Repository for Learning Python Programming--> Python is an Object Oriented Programming Language. An Open Source programming also an interpreted language. It is portable and easy to learn...! From c9f86b2b94c03633e0247ac1c844c0ed4bfbf6f3 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年9月16日 22:54:33 +0530 Subject: [PATCH 14/19] ICTAcadamy --- ICTAcadamy/Week-1/BreastCancer.py | 27 +++++++++++++++++++++++ ICTAcadamy/Week-1/DataFrame.py | 12 ++++++++++ ICTAcadamy/Week-1/LogisticRegression.py | 29 +++++++++++++++++++++++++ ICTAcadamy/Week-1/MergeFrame.py | 9 ++++++++ ICTAcadamy/Week-1/SKlearn.py | 23 ++++++++++++++++++++ ICTAcadamy/Week-2/NaturalLangToolKit.py | 11 ++++++++++ ICTAcadamy/Week-2/Vectorization.py | 19 ++++++++++++++++ 7 files changed, 130 insertions(+) create mode 100644 ICTAcadamy/Week-1/BreastCancer.py create mode 100644 ICTAcadamy/Week-1/DataFrame.py create mode 100644 ICTAcadamy/Week-1/LogisticRegression.py create mode 100644 ICTAcadamy/Week-1/MergeFrame.py create mode 100644 ICTAcadamy/Week-1/SKlearn.py create mode 100644 ICTAcadamy/Week-2/NaturalLangToolKit.py create mode 100644 ICTAcadamy/Week-2/Vectorization.py diff --git a/ICTAcadamy/Week-1/BreastCancer.py b/ICTAcadamy/Week-1/BreastCancer.py new file mode 100644 index 0000000..b7fdbf5 --- /dev/null +++ b/ICTAcadamy/Week-1/BreastCancer.py @@ -0,0 +1,27 @@ +import numpy as np +from sklearn import datasets +from sklearn.model_selection import train_test_split, GridSearchCV +from sklearn.svm import SVC +from sklearn.metrics import accuracy_score + + +breast_cancer = datasets.load_breast_cancer() +X = breast_cancer.data +y = breast_cancer.target + +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) + +svm = SVC(kernel='rbf') +param_grid = { + 'C': [0.1, 1, 10], + 'gamma': [0.001, 0.01, 0.1, 1] +} + +grid_search = GridSearchCV(estimator=svm, param_grid=param_grid, cv=5) +grid_search.fit(X_train, y_train) +best_params = grid_search.best_params_ +best_model = grid_search.best_estimator_ +y_pred = best_model.predict(X_test) +accuracy = accuracy_score(y_test, y_pred) + +print(accuracy) diff --git a/ICTAcadamy/Week-1/DataFrame.py b/ICTAcadamy/Week-1/DataFrame.py new file mode 100644 index 0000000..60e0ff3 --- /dev/null +++ b/ICTAcadamy/Week-1/DataFrame.py @@ -0,0 +1,12 @@ +import pandas as pd + +data={'a':[1,2],'b':[3,4],'c':[5,6]} + +df=pd.DataFrame(data) + +def float_value(x): + return x*1.0 + +df=df.apply(float_value) + +print(df) diff --git a/ICTAcadamy/Week-1/LogisticRegression.py b/ICTAcadamy/Week-1/LogisticRegression.py new file mode 100644 index 0000000..453cfca --- /dev/null +++ b/ICTAcadamy/Week-1/LogisticRegression.py @@ -0,0 +1,29 @@ +import numpy as np +import pandas as pd +from sklearn.datasets import load_breast_cancer +from sklearn.feature_selection import RFE +from sklearn.linear_model import LogisticRegression + +breast_cancer = load_breast_cancer() +X = breast_cancer.data +y = breast_cancer.target + +feature_names = breast_cancer.feature_names +df = pd.DataFrame(X, columns=feature_names) + + +model = LogisticRegression() +num_features_to_select = 5 +rfe = RFE(estimator=model, n_features_to_select=num_features_to_select) +rfe.fit(X, y) + + +selected_features = df.columns[rfe.support_] +feature_ranking = rfe.ranking_ + +feature_rank_df = pd.DataFrame({'Feature': df.columns, 'Ranking': feature_ranking}) + +sorted_feature_rank_df = feature_rank_df.sort_values(by='Ranking') + +print("Top {} Features:".format(num_features_to_select)) +print(sorted_feature_rank_df.head(num_features_to_select)) diff --git a/ICTAcadamy/Week-1/MergeFrame.py b/ICTAcadamy/Week-1/MergeFrame.py new file mode 100644 index 0000000..b25bf0e --- /dev/null +++ b/ICTAcadamy/Week-1/MergeFrame.py @@ -0,0 +1,9 @@ +import pandas as pd + +df1 = pd.DataFrame([['a', 1, 2], ['b', 2, 3], ['c', 4, 5]], columns=['A', 'B', 'C']) +df2 = pd.DataFrame([['a', 6, 7], ['a', 8, 9]], columns=['A', 'D', 'E']) + + +merged_df = df1.merge(df2, on='A', how='left') + +print(merged_df) diff --git a/ICTAcadamy/Week-1/SKlearn.py b/ICTAcadamy/Week-1/SKlearn.py new file mode 100644 index 0000000..83150d6 --- /dev/null +++ b/ICTAcadamy/Week-1/SKlearn.py @@ -0,0 +1,23 @@ +from sklearn.metrics import precision_score, recall_score, confusion_matrix + +x=[1,0,0,1,1] +y=[0,1,0,1,0] + +precision=precision_score(x,y) +recall=recall_score(x,y) + +print("Precision API : ",precision); +print("Recall API : ",recall); + +mat=confusion_matrix(x,y) + +true_negative=mat[0,0] +true_positive=mat[1,1] +false_negative=mat[0,1] +false_positive=mat[1,0] + +precision=true_positive/(true_positive+false_positive) +recall=true_positive/(true_positive+false_negative) + +print("Precision Confusion Matrix : ",precision); +print("Recall Confusion Matrix : ",recall); diff --git a/ICTAcadamy/Week-2/NaturalLangToolKit.py b/ICTAcadamy/Week-2/NaturalLangToolKit.py new file mode 100644 index 0000000..9be8534 --- /dev/null +++ b/ICTAcadamy/Week-2/NaturalLangToolKit.py @@ -0,0 +1,11 @@ +import nltk +from nltk import word_tokenize, pos_tag + +nltk.download("punkt") +nltk.download("averaged_perceptron_tagger") + +sentence = "The quick brown fox jumps over the lazy dog." + +words = word_tokenize(sentence) + +print(pos_tag(words)) diff --git a/ICTAcadamy/Week-2/Vectorization.py b/ICTAcadamy/Week-2/Vectorization.py new file mode 100644 index 0000000..47aaf49 --- /dev/null +++ b/ICTAcadamy/Week-2/Vectorization.py @@ -0,0 +1,19 @@ +import pandas as pd +from sklearn.feature_extraction.text import TfidfVectorizer + +documents = [ + "I am Nithin.", + "K Ramakrishnan Collge of Technology.", + "Fourth Year Student.", + "Consider me as Document Data", +] + +a = TfidfVectorizer() + +tfidf_matrix = a.fit_transform(documents) + +feature_names = a.get_feature_names_out() + +out = pd.DataFrame(data=tfidf_matrix.toarray(), columns=feature_names) + +print(out) From 36d8d4997730b8d3867bd5660e8fcd0f9494a4a2 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年9月17日 10:10:59 +0530 Subject: [PATCH 15/19] Create ClassObject.py --- OOPS/ClassObject.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 OOPS/ClassObject.py diff --git a/OOPS/ClassObject.py b/OOPS/ClassObject.py new file mode 100644 index 0000000..eebc559 --- /dev/null +++ b/OOPS/ClassObject.py @@ -0,0 +1,18 @@ +''' + +Classes and Object + + Create an class with constructor and get Person data and +display method to print the user details. + +''' + +class Person: + def __init__(self,name,age): + self.name=name + self.age=age + def display(self): + print("Name: ",self.name) + print("Age: ",self.age) +person=Person("Nithin",26) +person.display() From e27311d2c29e00d9a482d32a1982bfa8494f4d1e Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2023年12月16日 11:55:21 +0530 Subject: [PATCH 16/19] Create FloatFormating.c --- FloatFormating.c | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 FloatFormating.c diff --git a/FloatFormating.c b/FloatFormating.c new file mode 100644 index 0000000..2bacbdf --- /dev/null +++ b/FloatFormating.c @@ -0,0 +1,3 @@ +a,b=map(int,input().split()) +c=str(a)+"."+str(b) +print('{:.2f}'.format(float(c))); From 017dfb866fa4aa505e1a9a87820337122d7b04e7 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2024年1月22日 23:47:30 +0530 Subject: [PATCH 17/19] Create Function_Task.py --- Tasks/Function_Task.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Tasks/Function_Task.py diff --git a/Tasks/Function_Task.py b/Tasks/Function_Task.py new file mode 100644 index 0000000..630e91c --- /dev/null +++ b/Tasks/Function_Task.py @@ -0,0 +1,9 @@ +import math + +def calculate(radius): + area = math.pi * radius**2 + return area + +radius = float(input("Enter the radius of the circle: ")) +area = calculate(radius) +print(f"The area of the circle with radius {radius} is: {area:.2f}") From 12299b7c7794e986f57a466966eedfd15b7a73d9 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2024年1月23日 22:57:28 +0530 Subject: [PATCH 18/19] Create RandomNumber.py --- Tasks/RandomNumber.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Tasks/RandomNumber.py diff --git a/Tasks/RandomNumber.py b/Tasks/RandomNumber.py new file mode 100644 index 0000000..7d8fd78 --- /dev/null +++ b/Tasks/RandomNumber.py @@ -0,0 +1,7 @@ +import random + +def random(start, end): + return random.randint(start, end) + +random_number = generate_random_number(1, 100) +print(f"{random_number}") From 55640ec843d026b27b18fb05dee98cf76c8e11c9 Mon Sep 17 00:00:00 2001 From: Nithin U <106614289+nithinu2802@users.noreply.github.com> Date: 2024年1月27日 23:01:28 +0530 Subject: [PATCH 19/19] Create hasSubarraySum.py --- Tasks/hasSubarraySum.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Tasks/hasSubarraySum.py diff --git a/Tasks/hasSubarraySum.py b/Tasks/hasSubarraySum.py new file mode 100644 index 0000000..09a87ee --- /dev/null +++ b/Tasks/hasSubarraySum.py @@ -0,0 +1,16 @@ +def hasSubarraySum(arr, k): + prefix_sum = 0 + seen = {0} + + for num in arr: + prefix_sum += num + if prefix_sum - k in seen: + return True + seen.add(prefix_sum) + + return False + +arr = [11, 12, 34, 4, 2, 8, 9, 5] +k = 6 +result = hasSubarraySum(arr, k) +print(result)

AltStyle によって変換されたページ (->オリジナル) /