diff --git a/Networking/Check_site.py b/Networking/Check_site.py index 605832f..b14a213 100644 --- a/Networking/Check_site.py +++ b/Networking/Check_site.py @@ -1,5 +1,6 @@ import os +hostname ="https://binarynote.com" for i in range(2, 255): response = os.system("ping -4t " + hostname) diff --git a/Projects/Hangman_game.py b/Projects/Hangman_game.py index 2bf894d..8be9927 100644 --- a/Projects/Hangman_game.py +++ b/Projects/Hangman_game.py @@ -1,4 +1,4 @@ -9# Hangman Games +# Hangman Games # program by : rakesh kumar # website : https://cbsetoday.com @@ -6,7 +6,7 @@ import random as r # steps to select a random word from sowpods.txt file -with open("sowpods.txt") as file: +with open("c:/python/projects/sowpods.txt") as file: data = file.read().split() number = r.randint(0, len(data)) word = data[number] diff --git a/Tkinter/bindFunctionEvent.py b/Tkinter/bindFunctionEvent.py index a59df77..3ce1e15 100644 --- a/Tkinter/bindFunctionEvent.py +++ b/Tkinter/bindFunctionEvent.py @@ -5,7 +5,20 @@ def printName(event): print("hello my name is rakesh ") button1= Button(root,text="Print my Name") +button2= Button(root,text="Print my Name-2") +button3= Button(root,text="Print my Name-3") +button4= Button(root,text="Print my Name-4") +button5= Button(root,text="Print my Name-5") + button1.bind('',printName) +button2.bind('',printName) +button3.bind('',printName) +button4.bind('',printName) +button5.bind('',printName) button1.pack() +button2.pack() +button3.pack() +button4.pack() +button5.pack() root.mainloop() \ No newline at end of file diff --git a/Tkinter/messagebox.py b/Tkinter/messagebox.py index 37d42f3..048b864 100644 --- a/Tkinter/messagebox.py +++ b/Tkinter/messagebox.py @@ -1,10 +1,21 @@ from tkinter import * import tkinter.messagebox +import tkinter.simpledialog root = Tk() -tkinter.messagebox.showinfo('Window Title','This is the message') -answer = tkinter.messagebox.askyesno('Question',"Are you sure to delete this record ?") -if answer ==True : - print("You selected to delete record") +""" +yesno = tkinter.messagebox.askyesno('Question',"Are you sure to delete this record ?") +tkinter.messagebox.askokcancel() +tkinter.messagebox.askquestion() +tkinter.messagebox.askretrycancel() +tkinter.messagebox.askyesnocancel() -root.mainloop() \ No newline at end of file +if yesno ==True : + print("You selected to delete record") + """ + +no = tkinter.simpledialog.askstring('List Input','Enter number ') +no = no.split() +print(no) + +root.mainloop() diff --git a/Tkinter/tempCodeRunnerFile.py b/Tkinter/tempCodeRunnerFile.py new file mode 100644 index 0000000..58d09e5 --- /dev/null +++ b/Tkinter/tempCodeRunnerFile.py @@ -0,0 +1,3 @@ +yesno = tkinter.messagebox.askyesno('Question',"Are you sure to delete this record ?") +if yesno ==True : + print("You selected to delete record") \ No newline at end of file diff --git a/fileHandling/Find_lines_start_with_T.py b/fileHandling/Find_lines_start_with_T.py index 2bf0da7..a4bfad1 100644 --- a/fileHandling/Find_lines_start_with_T.py +++ b/fileHandling/Find_lines_start_with_T.py @@ -3,9 +3,9 @@ # made on : 07/07/2018 file = open(r"abcd.txt",'r') -count=0; +count=0 for line in file.readlines(): if line[0]=='T': count+=1 file.close() -print("Total lines that start with alphabet 'T' :",count) \ No newline at end of file +print("Total lines that start with alphabet 'T' :", count) \ No newline at end of file diff --git a/fileHandling/file_read.py b/fileHandling/file_read.py index 5aada0a..1786e67 100644 --- a/fileHandling/file_read.py +++ b/fileHandling/file_read.py @@ -1,4 +1,4 @@ -file = open(r"abcd.txt",'r') -data1 = file.read() +file = open("demo.txt") +data1 = file.read() # print(data1) file.close() \ No newline at end of file diff --git a/fileHandling/file_read_linewise.py b/fileHandling/file_read_linewise.py index 28db2df..1297eb3 100644 --- a/fileHandling/file_read_linewise.py +++ b/fileHandling/file_read_linewise.py @@ -2,10 +2,11 @@ #made by : rakesh kumar # made on : 07/07/2018 -file = open(r"abcd.txt",'r') -count=0; -for line in file.readlines(): - if "Project" in line.split(): - count+=1 -file.close() -print("Total 'Project' term available :",count) \ No newline at end of file + + +file = open("abcd.txt",'r') +data = file.readlines() +for line in data: + print(data) + +file.close() \ No newline at end of file diff --git a/fileHandling/result12_2020.py b/fileHandling/result12_2020.py new file mode 100644 index 0000000..2360e6c --- /dev/null +++ b/fileHandling/result12_2020.py @@ -0,0 +1,120 @@ +import csv +import re +import xlwt + + +def write2_cell(ws, row, roll, gender, name, marks): + ws.write(row, 0, roll) + ws.write(row, 1, name) + ws.write(row, 2, gender) + + for values in marks.values(): + if(values[0] == '301'): + ws.write(row, 3, values[1]) + if(values[0] == '302'): + ws.write(row, 4, values[1]) + if(values[0] == '041'): + ws.write(row, 5, values[1]) + if(values[0] == '042'): + ws.write(row, 6, values[1]) + if(values[0] == '043'): + ws.write(row, 7, values[1]) + if(values[0] == '283'): + ws.write(row, 8, values[1]) + if(values[0] == '265'): + ws.write(row, 9, values[1]) + if(values[0] == '044'): # biology + ws.write(row, 10, values[1]) + if(values[0] == '048'): # physical + ws.write(row, 11, values[1]) + if(values[0] == '030'): # economics + ws.write(row, 12, values[1]) + if(values[0] == '055'): # Accounts + ws.write(row, 13, values[1]) + if(values[0] == '054'): # BST + ws.write(row, 14, values[1]) + if(values[0] == '812'): # marketing + ws.write(row, 15, values[1]) + if(values[0] == '028'): # Pol science + ws.write(row, 16, values[1]) + if(values[0] == '034'): # music + ws.write(row, 17, values[1]) + if(values[0] == '049'): # music + ws.write(row, 18, values[1]) + + +file = open(r'C:\Users\rakesh\Desktop\z60074.txt', 'r') +rows = csv.reader(file) +wb = xlwt.Workbook() +ws = wb.add_sheet("result") +""" ws1 = wb.add_sheet("result1") """ + +st = xlwt.easyxf('font: bold yes;align: horiz centre , vert centre ,wrap yes') +ws.write(0, 0, "Roll No", st) +ws.write(0, 1, "Student Name", st) +ws.write(0, 2, "Gender", st) +ws.write(0, 3, "English", st) +ws.write(0, 4, "Hindi", st) +ws.write(0, 5, "Maths", st) +ws.write(0, 6, "Physics", st) +ws.write(0, 7, "Chemistry", st) +ws.write(0, 8, "CS", st) +ws.write(0, 9, "IP", st) +ws.write(0, 10, "Bio", st) +ws.write(0, 11, "Physical", st) +ws.write(0, 12, "Eco", st) +ws.write(0, 13, "Account", st) +ws.write(0, 14, "Bst", st) +ws.write(0, 15, "marketing", st) +ws.write(0, 16, "Pol Sci", st) +ws.write(0, 17, "Music", st) +ws.write(0, 18, "ART", st) +ws.write(0, 19, "result", st) + +n = 1 +count = 0 +for row in rows: + if(len(row) <= 0): + continue + else: + count += 1 + line1 = ''.join(row) + line2 = re.sub(' +', ' ', line1) + line3 = line2.split(' ') + if(count % 2 == 1): + sub = {} + roll = line3[0] + gender = line3[1] + name = line3[2] + " " + line3[3] + number = False + try: + sub[1] = ['' . join(line3[4])] + sub[2] = ['' . join(line3[5])] + sub[3] = ['' . join(line3[6])] + sub[4] = ['' . join(line3[7])] + sub[5] = ['' . join(line3[8])] + if(line3[9][0].isdigit()): + sub[6] = ['' . join(line3[9])] + number = True + except: + continue + + else: + try: + sub[1].append(line3[1]) + sub[2].append(line3[3]) + sub[3].append(line3[5]) + sub[4].append(line3[7]) + sub[5].append(line3[9]) + if number: + sub[6].append(line3[11]) + except: + print(roll, name, line3) + continue + + if(count % 2 == 0): + write2_cell(ws, n, roll, gender, name, sub) + n = n+1 + +wb.save(r"C:\Users\rakesh\Desktop\result123.xls") +print('File Generated.....Please check your file') diff --git a/fileHandling/tempCodeRunnerFile.py b/fileHandling/tempCodeRunnerFile.py index 40c766c..34c692b 100644 --- a/fileHandling/tempCodeRunnerFile.py +++ b/fileHandling/tempCodeRunnerFile.py @@ -1 +1 @@ - print(x) \ No newline at end of file +print("Total lines that start with alphabet 'T' :",count) \ No newline at end of file diff --git a/numpy/create_1.py b/numpy/create_1.py new file mode 100644 index 0000000..20943b5 --- /dev/null +++ b/numpy/create_1.py @@ -0,0 +1,7 @@ +import numpy as np +a = np.array([1, 2, 3, 4, 5, 5, 6, 7, 8]) +print(a[2]) +print(a[0]) +print(a[:3]) # slicing example +print(a[2:6]) +print(a[2::2]) diff --git a/pandas/df_access_column.py b/pandas/df_access_column.py index b5703ba..9321384 100644 --- a/pandas/df_access_column.py +++ b/pandas/df_access_column.py @@ -12,4 +12,7 @@ ] heading = ["admno", "name", "marks", "fees"] df = pd.DataFrame(data, columns=heading) -print(df[['name','fees']] +print(df['marks']+10) +print(df.marks>75) +print(df['marks'][df.marks>75]) + diff --git a/pandas/df_access_rows.py b/pandas/df_access_rows.py index a615797..f808ecf 100644 --- a/pandas/df_access_rows.py +++ b/pandas/df_access_rows.py @@ -12,4 +12,9 @@ ] heading = ["admno", "name", "marks", "fees"] df = pd.DataFrame(data, columns=heading) -print(df[1]) \ No newline at end of file +print(df.head()) +print(df.head(2)) +print(df.tail()) +print(df.tail(3)) +print(df[1:3]) + diff --git a/pandas/df_append.py b/pandas/df_append.py new file mode 100644 index 0000000..4de2967 --- /dev/null +++ b/pandas/df_append.py @@ -0,0 +1,17 @@ +# create dataframe using list of Tuple +import pandas as pd +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) +df = df.append({'admno': 9999, 'name': 'ramji', 'marks': 99, + 'fees': 9999.99}, ignore_index=True) +print(df) diff --git a/pandas/df_creation2.py b/pandas/df_creation2.py index 853c5ac..e1cd974 100644 --- a/pandas/df_creation2.py +++ b/pandas/df_creation2.py @@ -1,12 +1,18 @@ -# create dataframe using list of Python Dictionary +# create dataframe using list of Tuple import pandas as pd -df = pd.DataFrame( - [ - {'admno': 1101,'name': 'rakesh','marks' :56, 'fees': 5656.56}, - {'admno': 1203, 'name':'jatin jain','marks':56, 'fees': 5666.56}, - {'admno': 1205, 'name':'pushkar','marks':78, 'fees': 5666.56}, - {'admno': 1206, 'name':'arushi','marks':98, 'fees': 4564.34}, - {'admno': 1208, 'name':'mannat bhatia','marks':89, 'fees': 4500} - ] -) +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) print(df) +df = df.append({'admno': 9999, 'name': 'ramji', 'marks': 99, + 'fees': 9999.99,'grade':'a'}, ignore_index=True) +print(df) \ No newline at end of file diff --git a/pandas/df_delete_row_col.py b/pandas/df_delete_row_col.py new file mode 100644 index 0000000..1679832 --- /dev/null +++ b/pandas/df_delete_row_col.py @@ -0,0 +1,20 @@ +import pandas as pd +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) +#df = df.drop('fees',axis=1) +#df = df.drop(columns=['marks','fees']) +#df = df.drop(['marks','fees'],axis=1) +#df.drop('fees',axis=1,inplace=True) +df =df.drop([1,2,3],axis=0) # delete rows +print(df) + diff --git a/pandas/df_index_label.py b/pandas/df_index_label.py new file mode 100644 index 0000000..13805cb --- /dev/null +++ b/pandas/df_index_label.py @@ -0,0 +1,20 @@ +import pandas as pd +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), +] +data1 = [ + + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) +df1 = pd.DataFrame(data1, columns=heading) + +df2 = df.append(df1) # concatenation +print(df2) diff --git a/pandas/df_merge.py b/pandas/df_merge.py new file mode 100644 index 0000000..ca3260b --- /dev/null +++ b/pandas/df_merge.py @@ -0,0 +1,14 @@ +import pandas as pd + +right = pd.DataFrame({'admno': ['101', '102', '103', '104'], + 'Game': ['Cricket', 'BasketBall', 'Badminton', 'Swimming'], + 'Fee': [1200, 750, 800, 1500]}) +print(right['Fee'].count()) +print(right['Fee'].max()) +print(right['Fee'].min()) +print(right['Fee'].sum()) +print(right['Fee'].mean()) #average +print(right['Fee'].median()) #average +print(right['Fee'].std()) #standard daviation +print(right['Fee'].var()) #standard variance +print(right['Fee'].quantile()) # quantile of the values diff --git a/pandas/df_rename_Columns.py b/pandas/df_rename_Columns.py new file mode 100644 index 0000000..ca052cf --- /dev/null +++ b/pandas/df_rename_Columns.py @@ -0,0 +1,18 @@ +import pandas as pd +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) +#df =df.rename(columns={"fees":'Annual Fees'}) +#df = df.rename({'fees':'Yealy fees'},axis=1) +df = df.rename({'fees':'yealy fees', 'marks':'ut-2'}, axis=1) +#df.rename({'fees': 'yealy fees', 'marks': 'ut-2'}, axis=1,inplace=True) +print(df) diff --git a/pandas/df_saving.py b/pandas/df_saving.py new file mode 100644 index 0000000..8f7f523 --- /dev/null +++ b/pandas/df_saving.py @@ -0,0 +1,16 @@ +import pandas as pd +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) +#df.to_csv('student.csv',index=False) +df.to_excel('student_data.xlsx',"sheet-1", index=False) +print('Please check your file....') \ No newline at end of file diff --git a/pandas/index_label.py b/pandas/index_label.py new file mode 100644 index 0000000..a44c787 --- /dev/null +++ b/pandas/index_label.py @@ -0,0 +1,15 @@ +import pandas as pd +data = [ + (1101, 'rakesh', 56, 5656.56), + (1203, 'jatin jain', 56, 5666.56), + (1205, 'pushkar', 78, 5666.56), + (1206, 'arushi', 98, 4564.34), + (1208, 'mannat bhatia', 89, 4500), + (1234, 'unnati', 67, 3500.56), + (1245, 'Nikunj Tyagi', 68, 4500), + (5755, 'vishank', 89, 5000) +] +heading = ["admno", "name", "marks", "fees"] +df = pd.DataFrame(data, columns=heading) +df.set_index('admno') +print(df) \ No newline at end of file diff --git a/pandas/tempCodeRunnerFile.py b/pandas/tempCodeRunnerFile.py index 2233f99..f079489 100644 --- a/pandas/tempCodeRunnerFile.py +++ b/pandas/tempCodeRunnerFile.py @@ -1,4 +1 @@ -# create python pandas using Excel file -import pandas as pd -df = pd.read_excel("result.xls","result") -print(df) \ No newline at end of file +K0 \ No newline at end of file diff --git a/student.csv b/student.csv index 277c95e..ff8a5ed 100644 --- a/student.csv +++ b/student.csv @@ -1,5 +1,9 @@ -rollno,name,stream,fees -12,surendra,Humanities,2356 -13,Ashok Goyal,Humanities,2356 -15,Nipun,Humanities,2356 -22,Ayush Negi,Science,2356 \ No newline at end of file +admno,name,marks,fees +1101,rakesh,56,5656.56 +1203,jatin jain,56,5666.56 +1205,pushkar,78,5666.56 +1206,arushi,98,4564.34 +1208,mannat bhatia,89,4500.0 +1234,unnati,67,3500.56 +1245,Nikunj Tyagi,68,4500.0 +5755,vishank,89,5000.0 diff --git a/student_data.xlsx b/student_data.xlsx new file mode 100644 index 0000000..7944d64 Binary files /dev/null and b/student_data.xlsx differ diff --git a/webscraper/youtubeDownloader.py b/webscraper/youtubeDownloader.py index b855b37..f35c99a 100644 --- a/webscraper/youtubeDownloader.py +++ b/webscraper/youtubeDownloader.py @@ -4,5 +4,5 @@ # import shutil ydl_opts = {} with youtube_dl.YoutubeDL(ydl_opts) as ydl: - ydl.download(['https://www.youtube.com/watch?v=QaeXCar-NaM&t=2740s']) + ydl.download(['https://www.youtube.com/watch?v=WfGMYdalClU']) diff --git a/welcome.mp3 b/welcome.mp3 deleted file mode 100644 index eb89195..0000000 Binary files a/welcome.mp3 and /dev/null differ