├── file ├── data_writing ├── vowels_weriting ├── open_file.py ├── words_count.py ├── vowels_reading ├── open_file_reading ├── open_file_weriting ├── start_capital_latter.py ├── vowels.py ├── start_capital_latter_reading ├── start_capital_latter_weriting ├── data.py └── words_count ├── login ├── data_file.txt ├── oops │ ├── text.txt │ ├── __pycache__ │ │ └── class_oop.cpython-310.pyc │ ├── import_class_useing_login.py │ └── class_oop.py └── login_from.py ├── singline.py ├── modules ├── string_revers.py ├── __pycache__ │ ├── login.cpython-311.pyc │ ├── addition.cpython-311.pyc │ └── string_revers.cpython-311.pyc ├── addition.py ├── user.py └── login.py ├── problems ├── reverse words in a string.py ├── repeted_name.py ├── leader_number.py ├── dubilacate_valuse.py ├── regEx │ ├── regex_5th_problem.py │ ├── regex_4th_problem.py │ ├── regex_3rd_problem.py │ ├── regex_2nd_problem.py │ ├── regex_1st_problem.py │ ├── regex_6th_problem.py │ └── regex_7th_problem.py ├── string_print_in_without_loop.py ├── factorial.py ├── without_loop.py ├── stringrotate.py ├── count od rs_5 rs_2 and rs_1.py ├── subsequence.py ├── valid palindrome.py ├── rotate array.py ├── id_check.py ├── camelcase.py ├── duplicate_idendifi.py ├── subsequence_len().py ├── looping_problam.py ├── string_length.py ├── problam31_03_2024.py └── ice_cream_gift.py ├── tables.py ├── ABCD_pattern.py ├── function ├── add_function.py ├── class_string.py ├── class_empolyee.py └── class_student.py ├── nested loop.py ├── numpy_muliplaction_problem.py ├── Add two matrices ├── time_format.py ├── string_revers.py ├── male_or_female.py ├── substring_and_unic.py ├── right_password.py ├── latter_in_two_step_1.py ├── mobile_number_or_name_check.py ├── numby_add_problem.py ├── pandas_and_numpu_useing.py ├── number_batten_problam.py ├── pattern.py ├── pass mark calculator.py ├── string_problam.py ├── specil character_remove.py ├── latter_in_two_step_2.py ├── highscore_mark_name.py ├── problam_pandas.py ├── Tamil ├── tamil.txt ├── tamil_word_position.py └── tamil_word_position_with_txt.py ├── fastApi.py ├── Exception handling.py └── linked_list.py /file/data_writing: -------------------------------------------------------------------------------- 1 | hi -------------------------------------------------------------------------------- /login/data_file.txt: -------------------------------------------------------------------------------- 1 | vasanth,123 2 | -------------------------------------------------------------------------------- /file/vowels_weriting: -------------------------------------------------------------------------------- 1 | anandaraj 2 | arun 3 | -------------------------------------------------------------------------------- /login/oops/text.txt: -------------------------------------------------------------------------------- 1 | [vasanth,123] 2 | [hari,] 3 | -------------------------------------------------------------------------------- /singline.py: -------------------------------------------------------------------------------- 1 | print(varible := list(map(lambda x:x*2,[i for i in range(1,11)]))) 2 | -------------------------------------------------------------------------------- /modules/string_revers.py: -------------------------------------------------------------------------------- 1 | def string_revers(): 2 | string_revers = input("Enter the string:") 3 | print(string_revers[::-1]) -------------------------------------------------------------------------------- /modules/__pycache__/login.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vasanth2005kk/VGLUG/HEAD/modules/__pycache__/login.cpython-311.pyc -------------------------------------------------------------------------------- /modules/__pycache__/addition.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vasanth2005kk/VGLUG/HEAD/modules/__pycache__/addition.cpython-311.pyc -------------------------------------------------------------------------------- /login/oops/__pycache__/class_oop.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vasanth2005kk/VGLUG/HEAD/login/oops/__pycache__/class_oop.cpython-310.pyc -------------------------------------------------------------------------------- /modules/__pycache__/string_revers.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vasanth2005kk/VGLUG/HEAD/modules/__pycache__/string_revers.cpython-311.pyc -------------------------------------------------------------------------------- /problems/reverse words in a string.py: -------------------------------------------------------------------------------- 1 | s="a good example".split() 2 | #print(s) 3 | list_1=s[::-1] 4 | #print(list_1) 5 | for i in list_1: 6 | print(i,end=" ") -------------------------------------------------------------------------------- /modules/addition.py: -------------------------------------------------------------------------------- 1 | def addition(): 2 | a=int(input("Enter the A:")) 3 | b=int(input("Enter the A:")) 4 | print("Total:",a+b) 5 | 6 | addition() 7 | -------------------------------------------------------------------------------- /modules/user.py: -------------------------------------------------------------------------------- 1 | import login 2 | import addition 3 | import string_revers 4 | 5 | if login.login(): 6 | addition.addition() 7 | string_revers.string_revers() -------------------------------------------------------------------------------- /tables.py: -------------------------------------------------------------------------------- 1 | num=int(input("table number:")) 2 | table_end=int(input("enter the table ending:")) 3 | for j in range(1,table_end+1): 4 | print(j,"X",num,"=",j*num) 5 | -------------------------------------------------------------------------------- /ABCD_pattern.py: -------------------------------------------------------------------------------- 1 | ''' 2 | sample input: 6 3 | output : 4 | A 5 | ABA 6 | ABCBA 7 | ABCDCBA 8 | ABCDEDCBA 9 | ABCDEFEDCBA 10 | ''' -------------------------------------------------------------------------------- /function/add_function.py: -------------------------------------------------------------------------------- 1 | def add(): 2 | num_1=int(input("enter nunber 1:")) 3 | num_2=int(input("enter number 2:")) 4 | print("total:",num_1+num_2) 5 | add() 6 | -------------------------------------------------------------------------------- /function/class_string.py: -------------------------------------------------------------------------------- 1 | class string: 2 | def string_1(self): 3 | word=input("enter the string:") 4 | output=word[::-1] 5 | print(output) 6 | s1=string() 7 | s1.string_1() -------------------------------------------------------------------------------- /file/open_file.py: -------------------------------------------------------------------------------- 1 | file_1=open("open_file_reading","r") 2 | file_2=open("open_file_weriting","w") 3 | for line in file_1: 4 | #print(line,end="") 5 | file_2.write(line) 6 | file_1.close() 7 | file_2.close() -------------------------------------------------------------------------------- /problems/repeted_name.py: -------------------------------------------------------------------------------- 1 | num=int(input("enter the number:")) 2 | name_stord=[] 3 | for _ in range(num): 4 | n=input("enter the name:") 5 | name_stord.append(n) 6 | for i in set(name_stord): 7 | print("name:",i) -------------------------------------------------------------------------------- /nested loop.py: -------------------------------------------------------------------------------- 1 | #nested loops 2 | n=int(input("Give the n value :")) 3 | #2 for loops are used inside of a for loops 4 | for i in range(1,n+1): 5 | for j in range(1,i+1): 6 | print(j,end=" ") 7 | print("\n") 8 | -------------------------------------------------------------------------------- /file/words_count.py: -------------------------------------------------------------------------------- 1 | file_1=open('words_count','r') 2 | words=input("Enter the words and your choice:") 3 | count=0 4 | for line in file_1: 5 | count+=line.count(words) 6 | #print(line) 7 | print(count) 8 | file_1.close() -------------------------------------------------------------------------------- /numpy_muliplaction_problem.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | 3 | arr=numpy.array([[1,2,3],[4,5,6]]) 4 | arr_1=numpy.array([[10,20,30],[40,50,60],[70,80,90]]) 5 | 6 | a=list(arr.shape) 7 | b=list(arr_1.shape) 8 | 9 | if a[1]==b[0]: 10 | mulit=numpy.dot(arr,arr_1) 11 | print(mulit) -------------------------------------------------------------------------------- /file/vowels_reading: -------------------------------------------------------------------------------- 1 | nazrinbanu 2 | vasanth 3 | anandaraj 4 | ragu 5 | parthiban 6 | siva 7 | hari 8 | rahul 9 | dhinesh 10 | ragupathi 11 | vicky 12 | vinoth 13 | prveen 14 | selava 15 | suresh 16 | chanduru 17 | arun 18 | ranjith 19 | santhosh 20 | milkraj kovil -------------------------------------------------------------------------------- /problems/leader_number.py: -------------------------------------------------------------------------------- 1 | input_list=list(map(int,input().strip('[]').split(',')))#[16, 17, 4, 3, 2] 2 | 3 | print(input_list) 4 | 5 | for i in range(len(input_list)): 6 | 7 | if input_list[i] > sum([j for j in input_list[i+1:]]): 8 | print(input_list[i]) 9 | break 10 | -------------------------------------------------------------------------------- /problems/dubilacate_valuse.py: -------------------------------------------------------------------------------- 1 | s=['a', 'a', 'a', 'b', 'd', 'd', 'd'] 2 | 3 | list_1=[] 4 | list_2=[] 5 | 6 | for i in s: 7 | if not i in list_1: 8 | list_1.append(i) 9 | else: 10 | list_2.append(i) 11 | 12 | print('real valuse',list_1) 13 | print('dubilicate valuse',list_2) -------------------------------------------------------------------------------- /problems/regEx/regex_5th_problem.py: -------------------------------------------------------------------------------- 1 | #write a program that matches a number at the end of a string. 2 | 3 | import re 4 | string=input("Enter the string and ending in digit:") 5 | regex=re.findall("\d$",string) 6 | 7 | if regex: 8 | print("Matched") 9 | else: 10 | print("Not Matched") 11 | -------------------------------------------------------------------------------- /problems/string_print_in_without_loop.py: -------------------------------------------------------------------------------- 1 | try: 2 | def letters(l): 3 | s=0 4 | print(l[0]) 5 | if len(l) > s: 6 | s+=1 7 | letters(l[s:]) 8 | 9 | 10 | letter="vasanth" 11 | letters(letter) 12 | 13 | except Exception as e: 14 | pass -------------------------------------------------------------------------------- /file/open_file_reading: -------------------------------------------------------------------------------- 1 | huggingchat (Hugging Chat) 2 | WebHugging Chat. 3 | community. 4 | Research interests. 5 | None defined yet. 6 | Team members 7 | Organization Card. 8 | About org cards. 9 | Making the best open source AI chat models available to everyone. 10 | spaces 2. Sort: Recently -------------------------------------------------------------------------------- /file/open_file_weriting: -------------------------------------------------------------------------------- 1 | huggingchat (Hugging Chat) 2 | WebHugging Chat. 3 | community. 4 | Research interests. 5 | None defined yet. 6 | Team members 7 | Organization Card. 8 | About org cards. 9 | Making the best open source AI chat models available to everyone. 10 | spaces 2. Sort: Recently -------------------------------------------------------------------------------- /file/start_capital_latter.py: -------------------------------------------------------------------------------- 1 | file_1=open('start_capital_latter_reading','r') 2 | file_2=open('start_capital_latter_weriting','w') 3 | for line in file_1: 4 | #print(line.capitalize(),end=" ") 5 | #print(line.title(),end=" ") 6 | file_2.write(line.title()) 7 | file_1.close() 8 | file_2.close() -------------------------------------------------------------------------------- /problems/regEx/regex_4th_problem.py: -------------------------------------------------------------------------------- 1 | #Write a program that matches a word at the beginning of a string 2 | 3 | import re 4 | 5 | string=input("Enter The String:") 6 | regex=re.findall("^\w",string) 7 | 8 | if regex: 9 | print(f"Matched: {string}") 10 | else: 11 | print(f"Not Matched: {string}") -------------------------------------------------------------------------------- /file/vowels.py: -------------------------------------------------------------------------------- 1 | file_1=open('vowels_reading','r') 2 | file_2=open('vowels_weriting','w') 3 | vowels_list=["a","e","i","o","u","A","E","I","O","U"] 4 | for lines in file_1: 5 | if lines[0] in vowels_list: 6 | file_2.write(lines) 7 | print(lines,end="") 8 | file_1.close() 9 | file_2.close() -------------------------------------------------------------------------------- /modules/login.py: -------------------------------------------------------------------------------- 1 | def login(): 2 | user_name = input("user_name:") 3 | password = input("Possword:") 4 | name = "vasanth" 5 | password_set = "8220921078" 6 | if name == user_name and password_set == password: 7 | return True 8 | else: 9 | print("this password not right!") -------------------------------------------------------------------------------- /Add two matrices: -------------------------------------------------------------------------------- 1 | 2 | # Add two matrices 3 | A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 4 | B = [[9, 8, 7], [6, 5, 4], [3, 2, 1]] 5 | result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] 6 | 7 | for i in range(len(A)): 8 | for j in range(len(A[0])): 9 | result[i][j] = A[i][j] + B[i][j] 10 | 11 | for row in result: 12 | print(row) 13 | -------------------------------------------------------------------------------- /problems/factorial.py: -------------------------------------------------------------------------------- 1 | '''write a python program to find the sum of natural numbers upto N. 2 | sample input : 16 3 | sample output : the sum of natural numbers upto 16 is 136''' 4 | 5 | N=int(input("enter the value for N:")) 6 | number=0 7 | for i in range(1,N+1): 8 | number+=i 9 | print(f"the sum of natural number upto {N} is {number}") -------------------------------------------------------------------------------- /time_format.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a Python program to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. 3 | ''' 4 | # here some date and time changes are used to shows that 5 | import datetime 6 | input_date=list(map(int,input().split("-"))) 7 | date=datetime.datetime(2012,input_date[1],input_date[2]) 8 | print(date.strftime("%d-%m-%Y")) 9 | -------------------------------------------------------------------------------- /problems/regEx/regex_3rd_problem.py: -------------------------------------------------------------------------------- 1 | #write a program that matches a string that has an O followed by two to three 'k' 2 | 3 | import re 4 | 5 | string=input("Enter The String:") 6 | regex=re.findall("[k]",string) 7 | len_regex=len(regex) 8 | if len_regex==3 or len_regex==2: 9 | print("Matched") 10 | else: 11 | print("Not matched") -------------------------------------------------------------------------------- /problems/regEx/regex_2nd_problem.py: -------------------------------------------------------------------------------- 1 | '''wrtie a program that matches a string that has an N followed by one or more o's.''' 2 | 3 | import re 4 | 5 | string=input("Enter The String:") 6 | string_low=string.lower() 7 | regex=re.findall("^n.+",string) 8 | if regex: 9 | print(f"Matched: {string}") 10 | else: 11 | print(f"Not Matched: {string}") -------------------------------------------------------------------------------- /problems/regEx/regex_1st_problem.py: -------------------------------------------------------------------------------- 1 | '''Write a program that matches a string that has an N followed by zero or more o's''' 2 | 3 | import re 4 | 5 | string=input("enter the string:") 6 | string_1=string.lower() 7 | regex=re.findall("^n*o$",string_1) 8 | if regex: 9 | print(f"this ({string}) is matched") 10 | else: 11 | print(f"this ({string}) is not matched") -------------------------------------------------------------------------------- /string_revers.py: -------------------------------------------------------------------------------- 1 | # *Revers words in string -reverse all the words in givan string without changing words pepole i string 2 | # sample input: 3 | # Hello i am computer 4 | # sample output: 5 | # olleh i ma retupmoc 6 | 7 | string=input("Enter the string:").split(" ") 8 | for i in string: 9 | print(i[::-1],end=" ") 10 | print("helo") 11 | -------------------------------------------------------------------------------- /problems/without_loop.py: -------------------------------------------------------------------------------- 1 | # print for 1 to 100 in without loop 2 | 3 | def fun(x): 4 | if x<=100: 5 | print(x,end=" ") 6 | x+=1 7 | fun(x) 8 | 9 | 10 | x=1 11 | fun(x=x) 12 | 13 | 14 | def my_function(child3, child2, child1): 15 | print("The youngest child is " + child3) 16 | 17 | my_function(child1 = "Emil", child2 = "Tobias", child3 = "Linus") 18 | -------------------------------------------------------------------------------- /problems/regEx/regex_6th_problem.py: -------------------------------------------------------------------------------- 1 | ''' 2 | write a python program that matches a word containing 'z', not the start or end of the word. 3 | ''' 4 | 5 | import re 6 | 7 | string=input().lower() 8 | 9 | if re.findall("^z",string): 10 | print(" Not starting the in 'Z' ") 11 | elif re.findall("z$",string): 12 | print("Not end in the 'z' ") 13 | else: 14 | print("Successfully") -------------------------------------------------------------------------------- /function/class_empolyee.py: -------------------------------------------------------------------------------- 1 | class empolyee: 2 | def __init__(self,id,name,salary): 3 | self.id=id 4 | self.name=name 5 | self.salay=salary 6 | def getempolyee(self): 7 | print("empolyee ID:",self.id) 8 | print("empolyee name:",self.name) 9 | print("empolyee salary:",self.salay) 10 | emp1=empolyee("1234567","vasanth",50000) 11 | emp1.getempolyee() -------------------------------------------------------------------------------- /problems/stringrotate.py: -------------------------------------------------------------------------------- 1 | 2 | try : 3 | string_and_num=input().split(" ") 4 | 5 | 6 | if len(string_and_num[0]) > int(string_and_num[1]): 7 | 8 | output=string_and_num[0][int(string_and_num[1])-1:] 9 | 10 | print(output+string_and_num[0][0:int(string_and_num[1])-1]) 11 | else: 12 | print("outof range in seconde value !") 13 | 14 | except Exception as e: 15 | print("ERROR") 16 | -------------------------------------------------------------------------------- /male_or_female.py: -------------------------------------------------------------------------------- 1 | num=int(input("enter the number:")) 2 | 3 | stored_list=[] 4 | for _ in range(num): 5 | name_age_gender=input("enter th name , age and gender:").split(" ") 6 | stored_list.append(name_age_gender) 7 | 8 | for name,age,gendr in stored_list: 9 | if "male"==gendr or "m"==gendr: 10 | print(f"Mr.{name}") 11 | elif "female"==gendr or "f"==gendr: 12 | print(f"Ms.{name}") 13 | 14 | -------------------------------------------------------------------------------- /function/class_student.py: -------------------------------------------------------------------------------- 1 | class student: 2 | def __init__(self,name,roll_namber): 3 | self.name=name 4 | self.roll_namber=roll_namber 5 | def student_details(self): 6 | print("student name:",self.name) 7 | print("student roll_number:",self.roll_namber) 8 | std_1=student("vasanth",261444122) 9 | std_1=student("shandiya",261444123) 10 | std_1=student("celine",261444124) 11 | std_1.student_details() 12 | -------------------------------------------------------------------------------- /problems/count od rs_5 rs_2 and rs_1.py: -------------------------------------------------------------------------------- 1 | input_number=int(input("Enter the number:")) 2 | 3 | five=input_number//5 4 | five_remainder=input_number-(five*5) 5 | 6 | two=five_remainder//2 7 | two_remainder=input_number-(two*2)-(five*5) 8 | 9 | one=two_remainder 10 | 11 | if five != 0: 12 | print("Count of Rs 5 :",five) 13 | if two !=0 : 14 | print("Count of Rs 2 :",two) 15 | if one != 0: 16 | print("Count of Rs 1 :",one) -------------------------------------------------------------------------------- /substring_and_unic.py: -------------------------------------------------------------------------------- 1 | try: 2 | string=input('enter the string:') 3 | 4 | output=[] 5 | for i in range(len(string)): 6 | for j in range(i+2,len(string)+1): 7 | output.append(string[i:j]) 8 | 9 | for k in output: 10 | if len(set(list(k)))==len(list(k)): 11 | print(k) 12 | else: 13 | print("NOT unic elements !") 14 | 15 | except Exception as e: 16 | print("ERROR:",e) 17 | 18 | -------------------------------------------------------------------------------- /right_password.py: -------------------------------------------------------------------------------- 1 | #password chacking valide or unvalide 2 | 3 | string1=input("Enter the password :") #"Punith@123" 4 | 5 | if len(string1)>=7: 6 | if not string1.isalnum(): 7 | for i in string1: 8 | if i.isupper(): 9 | print("valide") 10 | break 11 | else: 12 | print("invalide") 13 | else: 14 | print("invalide") 15 | else: 16 | print("you give the password is 7 letter above the letters!") -------------------------------------------------------------------------------- /latter_in_two_step_1.py: -------------------------------------------------------------------------------- 1 | try: 2 | import string as s 3 | 4 | string = "welcome to vgluz" 5 | word = "" 6 | list_1 = [] 7 | 8 | for char in string: 9 | if char in s.ascii_lowercase: 10 | string_2 = chr((ord(char) - ord('a') + 2) % 26 + ord('a')) 11 | word += string_2 12 | else: 13 | word += char 14 | 15 | list_1.append(word) 16 | print(word) 17 | print(ord("a")) 18 | except Exception as e: 19 | print("Error:",e) -------------------------------------------------------------------------------- /login/oops/import_class_useing_login.py: -------------------------------------------------------------------------------- 1 | import class_oop as e 2 | 3 | class_varible=e.Usre 4 | 5 | print("1.register \n2.login \n{:^50}".format("-----closed for commed ( 0 or exit )-----")) 6 | 7 | keys=input(" Enter :") 8 | 9 | if keys=="1": 10 | output=class_varible(key=True) 11 | output.regestr() 12 | elif keys == "2": 13 | output=class_varible(key=False) 14 | output.login() 15 | elif keys.lower() == "exit" or keys=="0": 16 | pass 17 | else: 18 | print("Not this key ") -------------------------------------------------------------------------------- /problems/subsequence.py: -------------------------------------------------------------------------------- 1 | try: 2 | s = input("Enter the S:") 3 | t = input("Enter the T:") 4 | list_1 = [] 5 | list_1.extend(s) 6 | list_2 = [] 7 | list_2.extend(t) 8 | string = "" 9 | for i in list_2: 10 | for j in list_1: 11 | if i == j: 12 | string += j 13 | if s == string: 14 | print(True) 15 | else: 16 | print(False) 17 | except Exception as e: 18 | print("ERROR:",e) 19 | finally: 20 | print("Done") -------------------------------------------------------------------------------- /problems/valid palindrome.py: -------------------------------------------------------------------------------- 1 | try: 2 | s = "A man, a plan, a canal:panama" 3 | string = "" 4 | for letters in s: 5 | if letters.isalpha(): 6 | string += letters.lower() 7 | #print(string) 8 | reverse_string = string[::-1] 9 | #print(reverse_string) 10 | if string == reverse_string: 11 | print(True) 12 | else: 13 | print(False) 14 | except Exception as e: 15 | print(e) 16 | finally: 17 | print("<-------------------->\nDone") 18 | -------------------------------------------------------------------------------- /mobile_number_or_name_check.py: -------------------------------------------------------------------------------- 1 | call_name_or_number=input("Enter the name or mobile number :") 2 | 3 | #mobile number for the test 4 | call={ 5 | "8220921078":"vasanth", 6 | "9345858351":"santhosh", 7 | "9344838281":"ranjith", 8 | "1236537646":"vasanth" 9 | } 10 | for number,name in call.items(): 11 | if call_name_or_number==name: 12 | print(f"'{name}' number is : {number}") 13 | elif call_name_or_number==number: 14 | print(f"the number:{number} is ==> {name}") 15 | -------------------------------------------------------------------------------- /problems/rotate array.py: -------------------------------------------------------------------------------- 1 | """ 2 | k=3 3 | 1234567 --> 7654321 4 | 7654321 --> 567 4321 5 | 5674321 --> 567 1234 ==>5671234 6 | """ 7 | 8 | nums=[1,2,3,4,5,6,7] 9 | k=3 10 | nums_1=nums[::-1] 11 | list_1=[] 12 | for i in range(k): 13 | list_1.append(nums_1[i]) 14 | list_2=list_1[::-1] 15 | list_3=[] 16 | for j in nums_1: 17 | if j not in list_1 : 18 | list_3.append(j) 19 | list_4=list_3[::-1] 20 | for k in list_4: 21 | if list_2 not in list_4: 22 | list_2.append(k) 23 | print(list_2) -------------------------------------------------------------------------------- /problems/id_check.py: -------------------------------------------------------------------------------- 1 | data=[ 2 | {'id':20241001,'name':'ranjith'}, 3 | {'id':20241002,'name':'ragupathi'}, 4 | {'id':20241003,'name':'rishith'}, 5 | {'id':20241004,'name':'vasanth'}, 6 | {'id':20241005,'name':'santhosh'} 7 | ] 8 | error_block=[] 9 | id =int(input("Enter id to search :")) 10 | for i in data: 11 | if i['id'] == id : 12 | print(i) 13 | else: 14 | error_block.append(False) 15 | else: 16 | if not all(error_block): 17 | print("your data is not in the list !") 18 | -------------------------------------------------------------------------------- /problems/camelcase.py: -------------------------------------------------------------------------------- 1 | try: 2 | user_string=input("Enter the string :").split() 3 | 4 | letters=[chr(i) for i in range(65,91)] 5 | count=0 6 | 7 | for word in user_string: 8 | if not (word[0] in letters or word[-1] in letters) : 9 | 10 | for word_chracter in word: 11 | 12 | if word_chracter.isupper(): 13 | count+=1 14 | if count == 1: 15 | print(word) 16 | count=0 17 | 18 | except Exception as e: 19 | print("ERROR") -------------------------------------------------------------------------------- /problems/regEx/regex_7th_problem.py: -------------------------------------------------------------------------------- 1 | ''' 2 | write the pattern for find the email id format 3 | ''' 4 | try: 5 | import re 6 | 7 | email=input("Enter the mail : ") 8 | 9 | index_find=re.search("@",email).start() 10 | output=email[:index_find] 11 | 12 | if re.findall("@gmail.com$",email): 13 | if not re.findall("\W",output): 14 | print("successfully !") 15 | else: 16 | print("not this email !") 17 | else: 18 | print("not this email !") 19 | except Exception as e: 20 | print("Error:",e) -------------------------------------------------------------------------------- /numby_add_problem.py: -------------------------------------------------------------------------------- 1 | import numpy # Import the NumPy library for array operations 2 | 3 | # Create two 2D NumPy arrays 4 | arr = numpy.array([[1, 2, 3], [4, 5, 6]]) 5 | arr_1 = numpy.array([[10, 20, 30], [40, 50, 60]]) 6 | 7 | # Get the shapes of both arrays and convert them to lists 8 | a, b = list(arr.shape), list(arr_1.shape) 9 | 10 | # Check if the shapes of both arrays are the same 11 | if a == b: 12 | # If they are the same, perform element-wise addition of the two arrays 13 | output = arr + arr_1 14 | # Print the resulting array 15 | print(output) 16 | -------------------------------------------------------------------------------- /pandas_and_numpu_useing.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthew', 4 | 'Laura', 'Kevin', 'Jonas'], 5 | 'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], 6 | 'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1], 7 | 'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']} 8 | labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] 9 | 10 | 11 | 12 | a=pd.DataFrame(exam_data,index=labels) 13 | a["qualify"] == "yes" 14 | 15 | print(a) 16 | 17 | #universal function 18 | 19 | -------------------------------------------------------------------------------- /problems/duplicate_idendifi.py: -------------------------------------------------------------------------------- 1 | try: 2 | def _task(string1,string2): 3 | list_1=[] 4 | 5 | for i in string2: 6 | list_1.append(i) 7 | 8 | for j in string1: 9 | if j in list_1: 10 | list_1.remove(j) 11 | 12 | output="" 13 | for i in list_1: 14 | output+=i 15 | return output 16 | 17 | string1=input().split(" ") 18 | 19 | output=_task(string1[0],string1[1]) 20 | if output: 21 | print("Answer:",output) 22 | else: 23 | print("Not Answer !") 24 | 25 | except Exception as e: 26 | print(e) -------------------------------------------------------------------------------- /number_batten_problam.py: -------------------------------------------------------------------------------- 1 | # input:5 2 | # output: 3 | # # 1 4 | # # 1 2 1 5 | # # 1 2 3 2 1 6 | # # 1 2 3 4 3 2 1 7 | # # 1 2 3 4 5 4 3 2 1 8 | 9 | num=5#int(input("enter the number:")) 10 | 11 | # output=[] 12 | # values=[k for k in range(1,num)] 13 | # for i in range(1,num+1): 14 | # for j in range(1,i+1): 15 | # print(j,end=" ") 16 | # print((str(values[:i-1][::-1])).strip("[]").replace(',',""),end="") 17 | # print() 18 | 19 | 20 | 21 | for i in range(1,num+1): 22 | for j in range(1,i+1): 23 | print(j,end=" ") 24 | 25 | for k in range(i-1,0,-1): 26 | print(k,end=" ") 27 | print() 28 | 29 | -------------------------------------------------------------------------------- /pattern.py: -------------------------------------------------------------------------------- 1 | # Prompt the user to enter a number 2 | number = int(input()) 3 | 4 | # First method: Using string multiplication to print stars 5 | for i in range(1, number + 1): 6 | # Print i asterisks for each value of i from 1 to number 7 | print(i * "*") 8 | 9 | # the below thing are used for pattern !! 10 | print("<--------------------------->") 11 | 12 | for i in range(1, number + 1): 13 | # Inner loop to print one asterisk for each value of j up to i 14 | for j in range(i): 15 | print("*", end="") # Print asterisk without a newline 16 | print() # Print a newline after completing the inner loop for each i 17 | 18 | -------------------------------------------------------------------------------- /pass mark calculator.py: -------------------------------------------------------------------------------- 1 | '''get input as string with comma seperated number denoting marks of list of student in class room. 2 | print the array containg pass/fail respective to the input marks. 3 | consider 35 and above are pass marks 4 | 5 | sample input: 20,46,75,10 6 | sample output: fail,pass,pass,fail 7 | ''' 8 | 9 | studentmark=input("enter the mark:").split(" ") 10 | list_1=studentmark 11 | #print(list_1) 12 | pass_or_fail=[] 13 | for i in list_1: 14 | intger=int(i) 15 | if intger>=35: 16 | pass_or_fail.append("pass") 17 | else: 18 | pass_or_fail.append("fail") 19 | #print(pass_or_fail) 20 | for j in pass_or_fail: 21 | print(j,end=",") 22 | -------------------------------------------------------------------------------- /problems/subsequence_len().py: -------------------------------------------------------------------------------- 1 | try: 2 | s = input("enter the S:") 3 | t = input("enter the T:") 4 | if len(s) == len(t): 5 | list_1 = [] 6 | list_1.extend(t) 7 | # print(list_1) 8 | list_2 = [] 9 | list_2.extend(s) 10 | # print(list_2) 11 | string = "" 12 | for i in list_1: 13 | for j in list_2: 14 | if i == j: 15 | string += j 16 | if s == string: 17 | print(True) 18 | else: 19 | print(False) 20 | else: 21 | print(False) 22 | except Exception as e: 23 | print(e) 24 | finally: 25 | print("<------------------------>") 26 | print("Done") -------------------------------------------------------------------------------- /string_problam.py: -------------------------------------------------------------------------------- 1 | #1 2 | def letter(string): 3 | try: 4 | index=0 5 | output=[] 6 | 7 | for i in range(1,len(string)+1): 8 | output.append(i*string[index]) 9 | index+=1 10 | print("-".join(output).title()) 11 | except Exception as e: 12 | print("error:",e) 13 | input_string=input("enter the string :") 14 | letter(input_string) 15 | 16 | #2 17 | ''' 18 | def letters(string): 19 | try: 20 | index=0 21 | output="" 22 | for i in range(1,len(string)+1): 23 | print((i*string[index]).capitalize(),end="-") 24 | index+=1 25 | print() 26 | except Exception as e: 27 | print("Error",e) 28 | 29 | 30 | input_string=input("Enter the string:") 31 | 32 | letters(input_string) 33 | ''' -------------------------------------------------------------------------------- /problems/looping_problam.py: -------------------------------------------------------------------------------- 1 | prabha=[3,6,5,4,1,2] 2 | 3 | prabha=[a,b,c,d,e,f] 4 | prabha=[1,2,3,4,5,6] 5 | ''' 6 | 7 | ['e', 'f', 'a', 'd', 'c', 'b'] 8 | ['c', 'b', 'e', 'd', 'a', 'f'] 9 | ['a', 'f', 'c', 'd', 'e', 'b'] 10 | ['e', 'b', 'a', 'd', 'c', 'f'] 11 | ['c', 'f', 'e', 'd', 'a', 'b'] 12 | ['a', 'b', 'c', 'd', 'e', 'f'] 13 | 14 | ''' 15 | 16 | arr=[3,6,5,4,1,2] 17 | pepole=['a','b','c','d','e','f'] 18 | output=['','','','','',''] 19 | 20 | out=pepole.copy() 21 | 22 | total=0 23 | 24 | while True: 25 | for person,number in zip(out,arr): 26 | output[number-1]=person 27 | 28 | out=output.copy() 29 | print (out) 30 | total+=1 31 | 32 | if out==pepole: 33 | print('answer = ',total) 34 | break 35 | 36 | for i in range(1,10000000): 37 | print(i) 38 | -------------------------------------------------------------------------------- /specil character_remove.py: -------------------------------------------------------------------------------- 1 | '''write a python program to remove special caracters from an input string. the special characters to be removed are !@#$% 2 | 3 | sample input: wellcome ! t@o v$glu%g 4 | sample output: wellcome to vglug''' 5 | 6 | string="wellcome ! t@o v$glu%g" 7 | special_crate=["!","@","#","$","%"] 8 | letter=[] 9 | output="" 10 | for i in string: 11 | if i in special_crate: 12 | continue 13 | else: 14 | output+=i 15 | print(output) 16 | 17 | # or 18 | 19 | '''from string import punctuation 20 | 21 | string="wellcome ! t@o v$glu%g" 22 | output="" 23 | for i in string: 24 | if i in punctuation: 25 | continue 26 | else: 27 | output+=i 28 | print(output) 29 | ''' 30 | ''' 31 | string="wellcome ! t@o v$glu%g" 32 | spcila_cracter="!@#$%^&*()+_?><" 33 | new_string=string 34 | print(new_string) 35 | for i in spcila_cracter: 36 | new_string=new_string.replace(i,"") 37 | print(new_string) 38 | ''' -------------------------------------------------------------------------------- /problems/string_length.py: -------------------------------------------------------------------------------- 1 | import string as s 2 | word="good morning guys ! 1234" 3 | string=0 4 | number=0 5 | special_character=0 6 | for i in word: 7 | if i.isalpha(): 8 | string+=1 9 | elif i.isdigit(): 10 | number+=1 11 | elif i in s.punctuation: 12 | special_character+=1 13 | print("Word full length:",len(word)) 14 | print("letters:",string) 15 | print("Numbers:",number) 16 | print("Special_characters:",special_character) 17 | 18 | '''string="good morning ! 1234" 19 | list_1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] 20 | number_list=['1','2','3','4','5','6','7','8','9','0'] 21 | letter=0 22 | number=0 23 | sp_c=0 24 | space=" " 25 | for i in string: 26 | if i in list_1: 27 | letter+=1 28 | elif i in number_list: 29 | number+=1 30 | else: 31 | if i not in space: 32 | sp_c+=1 33 | print(letter) 34 | print(number) 35 | print(sp_c)''' 36 | -------------------------------------------------------------------------------- /latter_in_two_step_2.py: -------------------------------------------------------------------------------- 1 | try: 2 | letters = { 3 | "a": "c", 4 | "b": "d", 5 | "c": "e", 6 | "d": "f", 7 | "e": "g", 8 | "f": "h", 9 | "g": "i", 10 | "h": "j", 11 | "i": "k", 12 | "j": "l", 13 | "k": "m", 14 | "l": "n", 15 | "m": "o", 16 | "n": "p", 17 | "o": "q", 18 | "p": "r", 19 | "q": "s", 20 | "r": "t", 21 | "s": "u", 22 | "t": "v", 23 | "u": "w", 24 | "v": "x", 25 | "w": "y", 26 | "x": "z", 27 | "y": "a", 28 | "z": "b" 29 | } 30 | 31 | string = input("enter the string:").lower() 32 | output = "" 33 | 34 | for i in string: 35 | for key, value in letters.items(): 36 | if i == key: 37 | output += value 38 | if i == " ": 39 | output += " " 40 | print(output) 41 | except Exception as e: 42 | print("error:",e) 43 | -------------------------------------------------------------------------------- /highscore_mark_name.py: -------------------------------------------------------------------------------- 1 | '''write a python program to print the name of the student with highest mark. get the name & marks of N number of students as input. 2 | (e.g): 3 | enter the of students :3 4 | enter names & markes of each student :vasanth 5 | enter names & markes of each student :siva 54 6 | enter names & markes of each student :parthi 86 7 | output: 8 | parthi is highest mark.''' 9 | 10 | # Prompt the user for the number of students 11 | n = int(input("Enter the number of students:")) 12 | 13 | # Initialize an empty list to store names and marks 14 | list_1 = [] 15 | 16 | # Collect names and marks for each student 17 | for i in range(n): 18 | name_mark = input("Enter names & marks of each student: ").split() 19 | list_1.append(name_mark) # Add the list of name and mark to list_1 20 | 21 | # Initialize an empty list to store marks 22 | mark_list = [] 23 | 24 | # Extract marks from list_1 and convert them into integers 25 | for j, k in list_1: 26 | mark_list.append(int(k)) 27 | 28 | # Find and print the student with the highest mark 29 | for j, k in list_1: 30 | if int(k) == max(mark_list): # Check if the current mark is the maximum 31 | print(f"{j} has the highest mark.") 32 | -------------------------------------------------------------------------------- /problam_pandas.py: -------------------------------------------------------------------------------- 1 | import pandas as pd # Import the pandas library for data manipulation 2 | 3 | # Read the CSV file into a DataFrame 4 | output = pd.read_csv('datas.csv') 5 | 6 | # Initialize column and row boundaries 7 | col_strat = 0 8 | col_end = 5 9 | row_start = 0 10 | row_end = 10 11 | 12 | # Loop through the DataFrame in chunks of 10 rows 13 | for _ in range((len(output.axes[0]) + 1) // 10): 14 | # Loop through the DataFrame in chunks of 5 columns 15 | for _ in range((len(output.columns)) // 5): 16 | # Create a new DataFrame for the specified row and column slice 17 | df = pd.DataFrame(output.iloc[row_start:row_end, col_strat:col_end]) 18 | # Print the DataFrame as a string 19 | print(df.to_string()) 20 | 21 | # Update column boundaries for the next chunk 22 | col_strat += 5 23 | col_end += 5 24 | 25 | # Reset column boundaries for the next set of rows 26 | col_strat = 0 27 | col_end = 5 28 | 29 | # Update row boundaries for the next chunk of rows 30 | row_start += 10 31 | row_end += 10 32 | 33 | # Print a separator line for clarity 34 | print('<=============================================>\n<=============================================>') 35 | -------------------------------------------------------------------------------- /login/login_from.py: -------------------------------------------------------------------------------- 1 | file_heandling=open("data_file.txt","a") 2 | file_heandling_read=open("data_file.txt","r") 3 | 4 | print("1 press login page") 5 | print("2 press regester page") 6 | 7 | key=int(input("Enter :")) 8 | 9 | data_file_store=[] 10 | for i in file_heandling_read: 11 | data_file_store.append(i.split(",")) 12 | # login table 13 | if key==1: 14 | user_name=input("User Name:") 15 | password=input("Password:") 16 | for j in data_file_store: 17 | if user_name==j[0]: 18 | if password+"\n"==j[1]: 19 | print("\n Succefull ") 20 | else: 21 | print("\n Password is Not mached\n") 22 | else: 23 | print("\n Username is Not mached\n") 24 | 25 | #crate table 26 | if key==2: 27 | create_user_name=input("Enter your name :") 28 | create_password=input("Create your password :") 29 | return_password=input("Return your passsword :") 30 | if create_password==return_password: 31 | file_heandling.write(f"{create_user_name},{create_password}\n") 32 | print("\n Succefull\n") 33 | else: 34 | print(f"\nCreate your password and Retrun your password not mach !\n") 35 | print(f"proof:\n {create_password}\n {return_password}\n") 36 | -------------------------------------------------------------------------------- /problems/problam31_03_2024.py: -------------------------------------------------------------------------------- 1 | try: 2 | 3 | def string_split(string): 4 | string=string.upper() 5 | value='' 6 | split_value=[] 7 | 8 | for i in string: 9 | if i in ['1','2','3','4','5','6','7','8','9','0']: 10 | if 'S' == string[(string.find(i))-1]: 11 | value+=string[(string.find(i))-1]+i 12 | split_value.append(value) 13 | value='' 14 | elif i =='s' or i == 'S': 15 | continue 16 | else: 17 | split_value.append(i) 18 | return split_value 19 | 20 | number=[1,2,3,4,5,6] 21 | methods=string_split('rltdrrtrs22s1') 22 | print(methods) 23 | 24 | r_count=0 25 | for i in methods: 26 | if i=='R': 27 | r_count+=1 28 | elif i == 'L': 29 | r_count-=1 30 | elif i == 'T': 31 | number[r_count]=number[r_count]+1 32 | elif i == 'D': 33 | number[r_count]=number[r_count]-1 34 | elif i.startswith('S'): 35 | s_split=list(i) 36 | if len(number)>= int(s_split[1]): 37 | copy_number = number.copy() 38 | number[r_count] = number[int(s_split[1]) - 1] 39 | number[int(s_split[1]) - 1] = copy_number[r_count] 40 | 41 | print(number) 42 | 43 | except Exception as e: 44 | print(e) -------------------------------------------------------------------------------- /Tamil/tamil.txt: -------------------------------------------------------------------------------- 1 | பல நூற்றாண்டுகளாக செய்யுள் வடிவமே தமிழ் இலக்கியங்களிலும், தத்துவங்களிலும் பயன்படுத்தப்பட்டது. உரை வடிவம் இலக்கணங்களுக்கும், செய்யுள் விளக்கம் கூறவதற்கும், சாசனங்கள் (record) பதிவு செய்வதற்கும் பயன்படுத்தப்பட்டது. 20ஆம் நூற்றாண்டிலேயே உரை வடிவம் வளர்ச்சி செய்யுள் பெற்று, மக்களின் பல்வேறுபட்ட தேவைகளுக்கும் பயன்படுகின்றது. கட்டுரையே உரைநடை வெளிப்பாட்டின் முக்கிய வடிவம் end. 2 | 3 | பல நூற்றாண்டுகளாக செய்யுள் வடிவமே தமிழ் இலக்கியங்களிலும், தத்துவங்களிலும் பயன்படுத்தப்பட்டது. உரை வடிவம் இலக்கணங்களுக்கும், செய்யுள் விளக்கம் கூறவதற்கும், சாசனங்கள் (record) பதிவு செய்வதற்கும் பயன்படுத்தப்பட்டது. 20ஆம் நூற்றாண்டிலேயே உரை வடிவம் வளர்ச்சி செய்யுள் பெற்று, மக்களின் பல்வேறுபட்ட தேவைகளுக்கும் பயன்படுகின்றது. கட்டுரையே உரைநடை வெளிப்பாட்டின் முக்கிய வடிவம் end. 4 | 5 | பல நூற்றாண்டுகளாக செய்யுள் வடிவமே தமிழ் இலக்கியங்களிலும், தத்துவங்களிலும் பயன்படுத்தப்பட்டது. உரை வடிவம் இலக்கணங்களுக்கும், செய்யுள் விளக்கம் கூறவதற்கும், சாசனங்கள் (record) பதிவு செய்வதற்கும் பயன்படுத்தப்பட்டது. 20ஆம் நூற்றாண்டிலேயே உரை வடிவம் வளர்ச்சி செய்யுள் பெற்று, மக்களின் பல்வேறுபட்ட தேவைகளுக்கும் பயன்படுகின்றது. கட்டுரையே உரைநடை வெளிப்பாட்டின் முக்கிய வடிவம் end. 6 | பல நூற்றாண்டுகளாக செய்யுள் வடிவமே தமிழ் இலக்கியங்களிலும், தத்துவங்களிலும் பயன்படுத்தப்பட்டது. உரை வடிவம் இலக்கணங்களுக்கும், செய்யுள் விளக்கம் கூறவதற்கும், சாசனங்கள் (record) பதிவு செய்வதற்கும் பயன்படுத்தப்பட்டது. 20ஆம் நூற்றாண்டிலேயே உரை வடிவம் வளர்ச்சி செய்யுள் பெற்று, மக்களின் பல்வேறுபட்ட தேவைகளுக்கும் பயன்படுகின்றது. கட்டுரையே உரைநடை வெளிப்பாட்டின் முக்கிய வடிவம் end. -------------------------------------------------------------------------------- /Tamil/tamil_word_position.py: -------------------------------------------------------------------------------- 1 | # word position and replace the words in this program 2 | # this normal 3 | 4 | tamil_wordes=""" 5 | பல நூற்றாண்டுகளாக செய்யுள் வடிவமே தமிழ் இலக்கியங்களிலும், தத்துவங்களிலும் பயன்படுத்தப்பட்டது. உரை வடிவம் இலக்கணங்களுக்கும், செய்யுள் விளக்கம் கூறவதற்கும், சாசனங்கள் (record) பதிவு செய்வதற்கும் பயன்படுத்தப்பட்டது. 20ஆம் நூற்றாண்டிலேயே உரை வடிவம் வளர்ச்சி செய்யுள் பெற்று, மக்களின் பல்வேறுபட்ட தேவைகளுக்கும் பயன்படுகின்றது. கட்டுரையே உரைநடை வெளிப்பாட்டின் முக்கிய வடிவம் ஆகும். 6 | """.strip().split() 7 | 8 | input_word="செய்யுள்" 9 | repace_word="வசந்த்" 10 | 11 | index_position=0 12 | position_numbers=[] 13 | 14 | for i in tamil_wordes: 15 | index_position+=1 16 | if i == input_word: 17 | position_numbers.append(index_position) 18 | 19 | for word_positions in position_numbers: 20 | tamil_wordes.pop(word_positions-1) 21 | tamil_wordes.insert(word_positions-1,repace_word) 22 | 23 | print(" ".join(tamil_wordes)) 24 | 25 | 26 | # or 27 | 28 | tamil_wordes=""""" 29 | பல நூற்றாண்டுகளாக செய்யுள் வடிவமே தமிழ் இலக்கியங்களிலும், தத்துவங்களிலும் பயன்படுத்தப்பட்டது. உரை வடிவம் இலக்கணங்களுக்கும், செய்யுள் விளக்கம் கூறவதற்கும், சாசனங்கள் (record) பதிவு செய்வதற்கும் பயன்படுத்தப்பட்டது. 20ஆம் நூற்றாண்டிலேயே உரை வடிவம் வளர்ச்சி செய்யுள் பெற்று, மக்களின் பல்வேறுபட்ட தேவைகளுக்கும் பயன்படுகின்றது. கட்டுரையே உரைநடை வெளிப்பாட்டின் முக்கிய வடிவம் ஆகும். 30 | """""" 31 | 32 | input_word="செய்யுள்" 33 | repace_word="வசந்த்" 34 | 35 | replace_word_string=tamil_wordes.replace(input_word,repace_word) 36 | print(replace_word_string) 37 | -------------------------------------------------------------------------------- /Tamil/tamil_word_position_with_txt.py: -------------------------------------------------------------------------------- 1 | # position checking 2 | 3 | def position_checking(input_word): 4 | 5 | f=open('tamil.txt','r+') 6 | 7 | text_file=f.readlines() 8 | text_file_length=len(text_file) 9 | 10 | json_formate={} 11 | textline_and_position_values=[] 12 | position_number=0 13 | 14 | for index in range(text_file_length): 15 | positions=[] 16 | positions.append(f" line {index+1} positions ") 17 | 18 | for words in text_file[index].split(): 19 | position_number +=1 20 | if words == input_word: 21 | positions.append(position_number) 22 | position_number=0 23 | 24 | if len(positions) != 1: 25 | json_formate.update({positions[0]:positions[1::]}) 26 | 27 | return json_formate 28 | 29 | # answer=position_checking(input_word='செய்யுள்') 30 | # print(answer) 31 | 32 | 33 | # text file replace the values 34 | 35 | def file_replce_word(file_name,word,replace_word): 36 | reading_file_output=[] 37 | 38 | with open(file_name,"r") as reading_file: 39 | reading_file_output.append(reading_file.read().strip()) 40 | 41 | 42 | with open(file_name,"w") as write_file: 43 | 44 | for i in reading_file_output: 45 | replace_word_string=i.replace(word,replace_word) 46 | write_file.write(replace_word_string) 47 | 48 | 49 | file_name="tamil.txt" 50 | word="ஆகும்" 51 | replace_word="end" 52 | 53 | file_replce_word( 54 | file_name=file_name, 55 | word=word, 56 | replace_word=replace_word) -------------------------------------------------------------------------------- /fastApi.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, HTTPException 2 | from pydantic import BaseModel 3 | from typing import List, Optional 4 | 5 | # Create a FastAPI instance 6 | app = FastAPI() 7 | 8 | # Define a model for the items 9 | class Item(BaseModel): 10 | id: int 11 | name: str 12 | description: Optional[str] = None 13 | 14 | # In-memory storage for items 15 | items = [] 16 | 17 | # Create a new item 18 | @app.post("/items/", response_model=Item) 19 | def create_item(item: Item): 20 | items.append(item) 21 | return item 22 | 23 | # Read all items 24 | @app.get("/items/", response_model=List[Item]) 25 | def read_items(): 26 | return items 27 | 28 | # Read a specific item by ID 29 | @app.get("/items/{item_id}", response_model=Item) 30 | def read_item(item_id: int): 31 | for item in items: 32 | if item.id == item_id: 33 | return item 34 | raise HTTPException(status_code=404, detail="Item not found") 35 | 36 | # Update an existing item 37 | @app.put("/items/{item_id}", response_model=Item) 38 | def update_item(item_id: int, updated_item: Item): 39 | for index, item in enumerate(items): 40 | if item.id == item_id: 41 | items[index] = updated_item 42 | return updated_item 43 | raise HTTPException(status_code=404, detail="Item not found") 44 | 45 | # Delete an item 46 | @app.delete("/items/{item_id}", response_model=dict) 47 | def delete_item(item_id: int): 48 | for index, item in enumerate(items): 49 | if item.id == item_id: 50 | items.pop(index) 51 | return {"detail": "Item deleted"} 52 | raise HTTPException(status_code=404, detail="Item not found") 53 | 54 | # To run the app, use: uvicorn your_file_name:app --reload 55 | -------------------------------------------------------------------------------- /problems/ice_cream_gift.py: -------------------------------------------------------------------------------- 1 | try: 2 | list_1=input().split(" ") 3 | 4 | def ascci_counts(list_1): 5 | ascci_letters={ 6 | "a":1, 7 | "b":2, 8 | "c":3, 9 | "d":4, 10 | "e":5, 11 | "f":6, 12 | "g":7, 13 | "h":8, 14 | "i":9, 15 | "j":10, 16 | "k":11, 17 | "l":12, 18 | "m":13, 19 | "n":14, 20 | "o":15, 21 | "p":16, 22 | "q":17, 23 | "r":18, 24 | "s":19, 25 | "t":20, 26 | "u":21, 27 | "v":22, 28 | "w":23, 29 | "x":24, 30 | "y":25, 31 | "z":26, 32 | } 33 | 34 | storde=[] 35 | count=0 36 | for i in list_1: 37 | for j in set(i): 38 | count+=ascci_letters.get(j) 39 | storde.append(count) 40 | count=0 41 | return storde 42 | 43 | 44 | def counts(list_1): 45 | letter_lenth_count=[] 46 | 47 | for i in list_1: 48 | letter_lenth_count.append(len(i)) 49 | return letter_lenth_count 50 | 51 | 52 | num=(len(counts(list_1))) 53 | index=0 54 | output=[] 55 | 56 | if num==5: 57 | for i in range(num): 58 | if (counts(list_1)[index])>(ascci_counts(list_1)[index]): 59 | output.append(True) 60 | index+=1 61 | if output.count(True)>=5: 62 | print("Your Lucky I Will Gift for Ice Cream") 63 | else: 64 | print("Better Luck Next Time") 65 | else: 66 | print("Better Luck Next Time") 67 | 68 | except Exception as e: 69 | print("Error :",e) -------------------------------------------------------------------------------- /file/start_capital_latter_reading: -------------------------------------------------------------------------------- 1 | Subject: Weekly Delivery of Essential Products for Our Restaurant 2 | 3 | Dear [Supplier's Name], 4 | 5 | I hope this email finds you well. 6 | My name is [Your Name], and I am the owner of [Restaurant Name], located at [Address]. 7 | We have been in business for several years now, and we take great pride in providing our customers with high-quality food and exceptional service. 8 | 9 | We are reaching out to request your assistance in ensuring that we can continue to deliver on our promise to our 10 | patrons by placing a weekly order for essential products from your esteemed company. 11 | As per our discussion over the phone yesterday, 12 | we would like to place an order for the following items on a weekly basis: 13 | 14 | * Wine (10 bottles) 15 | * Eggs (24 pieces) 16 | * Bread (12 loaves) 17 | 18 | We understand that maintaining a consistent supply chain is crucial to the success of any business, 19 | and we believe that partnering with a reliable supplier such as yourself will help us achieve our goals. 20 | Your prompt response regarding the availability of these items and their delivery schedule would be greatly appreciated. 21 | 22 | In addition, we would appreciate it if you could provide us with a quote for the above-mentioned items, 23 | including any applicable discounts or promotions that you may be offering currently. 24 | This information will enable us to make informed decisions about our orders and ensure that we are getting the best value for our money. 25 | 26 | Please feel free to contact me directly should you require any additional information or clarification regarding our requirements. 27 | We look forward to hearing back from you soon and potentially establishing a long-term partnership with your company. 28 | 29 | Thank you for your time and consideration. 30 | 31 | Best regards, 32 | 33 | [Your Name] 34 | Owner, [Restaurant Name] -------------------------------------------------------------------------------- /file/start_capital_latter_weriting: -------------------------------------------------------------------------------- 1 | Subject: Weekly Delivery Of Essential Products For Our Restaurant 2 | 3 | Dear [Supplier'S Name], 4 | 5 | I Hope This Email Finds You Well. 6 | My Name Is [Your Name], And I Am The Owner Of [Restaurant Name], Located At [Address]. 7 | We Have Been In Business For Several Years Now, And We Take Great Pride In Providing Our Customers With High-Quality Food And Exceptional Service. 8 | 9 | We Are Reaching Out To Request Your Assistance In Ensuring That We Can Continue To Deliver On Our Promise To Our 10 | Patrons By Placing A Weekly Order For Essential Products From Your Esteemed Company. 11 | As Per Our Discussion Over The Phone Yesterday, 12 | We Would Like To Place An Order For The Following Items On A Weekly Basis: 13 | 14 | * Wine (10 Bottles) 15 | * Eggs (24 Pieces) 16 | * Bread (12 Loaves) 17 | 18 | We Understand That Maintaining A Consistent Supply Chain Is Crucial To The Success Of Any Business, 19 | And We Believe That Partnering With A Reliable Supplier Such As Yourself Will Help Us Achieve Our Goals. 20 | Your Prompt Response Regarding The Availability Of These Items And Their Delivery Schedule Would Be Greatly Appreciated. 21 | 22 | In Addition, We Would Appreciate It If You Could Provide Us With A Quote For The Above-Mentioned Items, 23 | Including Any Applicable Discounts Or Promotions That You May Be Offering Currently. 24 | This Information Will Enable Us To Make Informed Decisions About Our Orders And Ensure That We Are Getting The Best Value For Our Money. 25 | 26 | Please Feel Free To Contact Me Directly Should You Require Any Additional Information Or Clarification Regarding Our Requirements. 27 | We Look Forward To Hearing Back From You Soon And Potentially Establishing A Long-Term Partnership With Your Company. 28 | 29 | Thank You For Your Time And Consideration. 30 | 31 | Best Regards, 32 | 33 | [Your Name] 34 | Owner, [Restaurant Name] -------------------------------------------------------------------------------- /login/oops/class_oop.py: -------------------------------------------------------------------------------- 1 | class Usre: 2 | def __init__(self,key): 3 | if key: 4 | self.user_name=input("Enter your name :") 5 | self.password=input("Enter the password :") 6 | self.retrypassword=input("Retry password :") 7 | else: 8 | self.user_name_login=input("User name :") 9 | self.password_login=input("password :") 10 | 11 | def use_name_check(check_name): 12 | data=[] 13 | with open("text.txt","r") as f: 14 | for i in f.readlines(): 15 | output=i.strip("[]\n") 16 | data.append(output.split(",")) 17 | for j in data: 18 | if j[0] == check_name: 19 | return True 20 | else: 21 | return False 22 | 23 | def regestr(self): 24 | 25 | if self.user_name: 26 | 27 | if Usre.use_name_check(self.user_name): 28 | print("alredy user name difined !") 29 | 30 | else: 31 | if self.password==self.retrypassword: 32 | with open("text.txt","a") as file_appending: 33 | file_appending.write(f"[{self.user_name},{self.password}]\n") 34 | 35 | else: 36 | print("password is not mached!") 37 | else: 38 | print("type for u name") 39 | 40 | 41 | def login(self): 42 | data=[] 43 | with open("text.txt","r") as f: 44 | for i in f.readlines(): 45 | output=i.strip("[]\n") 46 | data.append(output.split(",")) 47 | for i in data: 48 | if self.user_name_login==i[0]: 49 | if self.password_login==i[1]: 50 | print("scessfully !") 51 | break 52 | else: 53 | print("{msg:^50}".format(msg="------------------ not this name ----------------".title())) 54 | -------------------------------------------------------------------------------- /Exception handling.py: -------------------------------------------------------------------------------- 1 | try:# TRY BLOCK 2 | # Prompt the user for a number and convert it to an integer 3 | num = int(input("Enter the number:")) 4 | 5 | # Initialize an empty list to store sums of valid combinations 6 | list_2 = [] 7 | 8 | # Iterate over possible values of i from 1 to num 9 | for i in range(1, num + 1): 10 | # Iterate over possible values of j from 1 to i 11 | for j in range(1, i + 1): 12 | # Iterate over possible values of k from 1 to j 13 | for k in range(1, j + 1): 14 | # Check if the product of i, j, and k equals the input number 15 | if i * j * k == num: 16 | # Print the combination found 17 | print([i, j, k], "===>", end=" ") 18 | # Calculate the sum of i, j, and k 19 | list_1 = i + j + k 20 | print(list_1) # Print the sum 21 | # Append the sum to list_2 22 | list_2.append(list_1) 23 | 24 | # Initialize lists to store unique sums and their occurrences 25 | list_3 = [] 26 | list_4 = [] 27 | 28 | # Iterate through the sums in list_2 29 | for i in list_2: 30 | # If the sum is not in list_3, add it 31 | if i not in list_3: 32 | list_3.append(i) 33 | # If the sum is already in list_3 but not in list_4, add it to list_4 34 | elif i not in list_4: 35 | list_4.append(i) 36 | 37 | # Print a separator line 38 | print("<_______________________________________________________________>") 39 | 40 | # Iterate through unique sums in list_4 41 | for i in list_4: 42 | # Print the answer if it is not empty 43 | if i: 44 | print("answer is: ===>", i) 45 | except ValueError as error: # EXCEPTION BLOCK OR ERROR BLOCK 46 | # Handle non-integer input errors 47 | print("ERROR ==>", error) 48 | finally:# FINALLY BLOCK 49 | # Print a message indicating that the process is done 50 | print("Done") 51 | -------------------------------------------------------------------------------- /file/data.py: -------------------------------------------------------------------------------- 1 | file_1=open('data_writing','w') 2 | emt_list=[] 3 | while True: 4 | line=input("enterthe string:") 5 | if line: 6 | emt_list.append(line) 7 | else: 8 | break 9 | output=" ".join(emt_list) 10 | print(output) 11 | file_1.write(output) 12 | file_1.close() 13 | 14 | 15 | import os 16 | 17 | def create_file(filename): 18 | try: 19 | with open(filename, 'w') as f: 20 | f.write('Hello, world!\n') 21 | print("File " + filename + " created successfully.") 22 | except IOError: 23 | print("Error: could not create file " + filename) 24 | 25 | def read_file(filename): 26 | try: 27 | with open(filename, 'r') as f: 28 | contents = f.read() 29 | print(contents) 30 | except IOError: 31 | print("Error: could not read file " + filename) 32 | 33 | def append_file(filename, text): 34 | try: 35 | with open(filename, 'a') as f: 36 | f.write(text) 37 | print("Text appended to file " + filename + " successfully.") 38 | except IOError: 39 | print("Error: could not append to file " + filename) 40 | 41 | def rename_file(filename, new_filename): 42 | try: 43 | os.rename(filename, new_filename) 44 | print("File " + filename + " renamed to " + newfilename + " successfully.") 45 | except IOError: 46 | print("Error: could not rename file " + filename) 47 | 48 | def delete_file(filename): 49 | try: 50 | os.remove(filename) 51 | print("File " + filename + " deleted successfully.") 52 | except IOError: 53 | print("Error: could not delete file " + filename) 54 | 55 | 56 | if __name__ == '__main__': 57 | filename = "bharathi.txt" 58 | new_filename = "new_example.txt" 59 | 60 | create_file(filename) 61 | read_file(filename) 62 | append_file(filename, "This is some additional text.\n") 63 | read_file(filename) 64 | rename_file(filename, new_filename) 65 | read_file(new_filename) 66 | delete_file(new_filename) 67 | -------------------------------------------------------------------------------- /file/words_count: -------------------------------------------------------------------------------- 1 | Home » Python » File Handling » Python Count Number of Files in a Directory 2 | Python Count Number of Files in a Directory 3 | Updated on: January 19, 2022 | 3 Comments 4 | 5 | In this article, we will see how to count the number of files present in a directory in Python. 6 | 7 | If the directory contains many files and you want to count the number of files present in a directory before performing any operations. 8 | For example, you want to move all files from one directory to another. 9 | Still, before moving them, 10 | we can count how many files are present in a directory to understand its impact and the time required to perform that operation. 11 | 12 | There are multiple ways to count files of a directory. We will use the following four methods. 13 | 14 | Table of contents 15 | How to count Files in a directory 16 | Example: Count Number Files in a directory 17 | Count all files in the directory and its subdirectories 18 | scandir() to count all files in the directory 19 | fnmatch module to count all files in the directory 20 | 21 | How to count Files in a directory 22 | Getting a count of files of a directory is easy as pie! Use the listdir() and isfile() functions of an 23 | os module to count the number of files of a directory. Here are the steps. 24 | 25 | Import os module 26 | The os module provides many functions for interacting with the operating system. 27 | Using the os module, we can perform many file-related operations such as moving, copying, renaming, and deleting files. 28 | 29 | create a counter variable 30 | Set counter to zero. This counter variable contains how many files are present in a directory. 31 | 32 | Use os.listdir() function 33 | The os.listdir('path') function returns a list of files and directories present in the given directory. 34 | 35 | Iterate the result 36 | Use for loop to Iterate the entries returned by the listdir() function. Using for loop we will iterate each entry returned by the listdir() function. 37 | 38 | Use isfile() function and increment counter by 1 39 | In each loop iteration, use the os.path.isfile('path') function to check whether the current entry is a file or directory. 40 | If it is a file, increment the counter by 1. -------------------------------------------------------------------------------- /linked_list.py: -------------------------------------------------------------------------------- 1 | # 1 2 | 3 | class Node: 4 | def __init__(self,val=0,next=None): 5 | self.val = val 6 | self.next = next 7 | 8 | l1=Node(2,Node(4,Node(3))) 9 | l2=Node(5,Node(6,Node(4))) 10 | 11 | def print_head(head): 12 | cournt=head 13 | while cournt is not None: 14 | print(cournt.val,end=" -> ") 15 | cournt=cournt.next 16 | 17 | print_head(l1) 18 | print() 19 | print_head(l2) 20 | 21 | # 2 22 | class ListNode: 23 | def __init__(self, val=0, next=None): 24 | self.val = val 25 | self.next = next 26 | 27 | def addTwoNumbers(l1, l2): 28 | dummy = ListNode() 29 | current = dummy 30 | carry = 0 31 | 32 | while l1 or l2 or carry: 33 | val1 = l1.val if l1 else 0 34 | val2 = l2.val if l2 else 0 35 | 36 | # Calculate the sum and carry 37 | total = val1 + val2 + carry 38 | carry = total // 10 39 | sum_val = total % 10 40 | 41 | # Create a new node with the sum value 42 | current.next = ListNode(sum_val) 43 | 44 | # Move the current pointer 45 | current = current.next 46 | 47 | # Move l1 and l2 pointers to their next nodes 48 | if l1: 49 | l1 = l1.next 50 | if l2: 51 | l2 = l2.next 52 | 53 | return dummy.next 54 | 55 | # Example usage: 56 | # Creating first number: 342 (represented as 2 -> 4 -> 3) 57 | l1 = ListNode(2, ListNode(4, ListNode(3))) 58 | # Creating second number: 465 (represented as 5 -> 6 -> 4) 59 | l2 = ListNode(5, ListNode(6, ListNode(4))) 60 | 61 | 62 | # Adding the two numbers 63 | result = addTwoNumbers(l1, l2) 64 | 65 | # Print the result list 66 | def print_list(head): 67 | current = head 68 | while current: 69 | print(current.val, end=" -> ") 70 | current = current.next 71 | print("None") 72 | 73 | print_list(result) # Output should be: 7 -> 0 -> 8 -> None (807) 74 | 75 | 76 | # 3 77 | class ListNode: 78 | def __init__(self, val=0, next=None): 79 | self.val = val 80 | self.next = next 81 | class Solution: 82 | def addTwoNumbers(self,l1,l2): 83 | l1_copy=[] 84 | for i in range(len(l1)): 85 | cournt=ListNode(l1[i]) 86 | l1_copy.append(str(cournt.val)) 87 | cournt.next = cournt 88 | l1_copy_ans=int("".join(l1_copy[::-1])) 89 | 90 | l2_copy=[] 91 | for i in range(len(l2)): 92 | cournt=ListNode(l2[i]) 93 | l2_copy.append(str(cournt.val)) 94 | cournt.next = cournt 95 | l2_copy_ans=int("".join(l2_copy[::-1])) 96 | 97 | return list(map(int,list(str(l1_copy_ans+l2_copy_ans))[::-1])) 98 | 99 | obj=Solution().addTwoNumbers(l1=[2,4,3],l2=[5,6,4]) 100 | print(obj) 101 | 102 | --------------------------------------------------------------------------------