diff --git a/DataStructure/binary_search.py b/DataStructure/binary_search.py index 26793c8..25d5a21 100644 --- a/DataStructure/binary_search.py +++ b/DataStructure/binary_search.py @@ -1,26 +1,23 @@ +def binary_search(x, first, last, data): + if(first > last): + return 0 + else: + mid = (first+last)//2 + if(x[mid] == data): + return 1 + if(x[mid] < data): + return binary_search(x, mid+1, last, data) + if(x[mid] > data): + return binary_search(x, first, mid-1, data) + + x = [1, 2, 3, 5, 7, 8, 9, 10, 12, 14, 15, 18, 20, 22] -data = 10 +data = 15 +first = 0 +last = 13 -# bad way to find data in tuple -''' found =0 -first=0 -last =13 -while (first<=last and found ==0): - mid = int((first+last)/2) - # print(mid) - if(x[mid]==data): - found =1 - if(x[mid]data): - last = mid-1 -if(found ==0): +result = binary_search(x, first, last, data) +if(result == 0): print("Data not found") else: print("Data found") - - ''' -if data in x: - print("Data found") -else: - print("Not found") diff --git a/DataStructure/linear_search.py b/DataStructure/linear_search.py index a638834..df5b917 100644 --- a/DataStructure/linear_search.py +++ b/DataStructure/linear_search.py @@ -1,18 +1,14 @@ -#wrong way to find data -x =[1,2,3,5,7,89,3,62,34,13,5,7,9] +# wrong way to find data +x = [1, 2, 3, 5, 7, 89, 3, 62, 34, 13, 5, 7, 9] data = 89 -''' found =0 +found = 0 + for i in x: - if i ==data: - found =1 -if(found ==0): - print("Data not found") -else: - print("Data found") ''' + if i == data: + found = 1 -# good way to search data in python -if data in x: - print('found') +if(found == 0): + print("Data not found") else: - print('not found') + print("Data found") diff --git a/DataStructure/tempCodeRunnerFile.py b/DataStructure/tempCodeRunnerFile.py new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/DataStructure/tempCodeRunnerFile.py @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/database/12CS/dflsdjfhjas.py b/database/12CS/dflsdjfhjas.py new file mode 100644 index 0000000..a665ac6 --- /dev/null +++ b/database/12CS/dflsdjfhjas.py @@ -0,0 +1,4 @@ +def (n=20, o=30): +a = n*o +return a +print(a) \ No newline at end of file diff --git a/database/12CS/insert_row.py b/database/12CS/insert_row.py index 70c9ae7..7670256 100644 --- a/database/12CS/insert_row.py +++ b/database/12CS/insert_row.py @@ -1,6 +1,6 @@ import MySQLdb db = MySQLdb.connect('localhost', 'root', '', 'davschool') cursor = db.cursor() -cursor.execute('insert into games values (6,"Python fun")') +cursor.execute('insert into games values (7,"fun with class xii")') db.close() print('Record added successfully') diff --git a/database/12CS/select_single_word.py b/database/12CS/select_single_word.py index dd6af77..7d1d895 100644 --- a/database/12CS/select_single_word.py +++ b/database/12CS/select_single_word.py @@ -1,7 +1,7 @@ import MySQLdb db = MySQLdb.connect('localhost', 'root', '', 'davschool') cursor = db.cursor() -cursor.execute('select gname from games where id=6') +cursor.execute('select gname from games where id=5') game_name = cursor.fetchone() print('Your Game is :', game_name) db.close() diff --git a/database/12CS/tempCodeRunnerFile.py b/database/12CS/tempCodeRunnerFile.py index 19d5a34..9643d20 100644 --- a/database/12CS/tempCodeRunnerFile.py +++ b/database/12CS/tempCodeRunnerFile.py @@ -1,9 +1 @@ -import MySQLdb -db = MySQLdb.connect('localhost', 'root', '', 'davschool') -cursor = db.cursor() -cursor.execute('select id,gname from games where id=6') -game_name = cursor.fetchone() -print('Your Game is :', game_name) -print('Game Id :', game_name[0]) -print('Game name :', game_name[1]) -db.close() +game_name \ No newline at end of file diff --git a/database/12CS/update_record.py b/database/12CS/update_record.py index 564dfa0..1119ca6 100644 --- a/database/12CS/update_record.py +++ b/database/12CS/update_record.py @@ -1,6 +1,6 @@ import MySQLdb db = MySQLdb.connect('localhost', 'root', '', 'davschool') cursor = db.cursor() -cursor.execute('update games set gname ="fun with python " where id=6') +cursor.execute('update games set gname ="fun with rakesh " where id=5') db.close() print('Record updated successfully') diff --git a/fileHandling/Bulk_Image_Resizer.py b/fileHandling/Bulk_Image_Resizer.py index c7cf94f..2e6f01b 100644 --- a/fileHandling/Bulk_Image_Resizer.py +++ b/fileHandling/Bulk_Image_Resizer.py @@ -20,7 +20,7 @@ def small(source,target,original): dest = target + '\\' +original with open(original, 'r+b') as f: with Image.open(f) as image: - cover = resizeimage.resize_cover(image, [800, 600], validate=False) + cover = resizeimage.resize_cover(image, [300, 200], validate=False) cover.save(dest, image.format) def deleteFiles(): diff --git a/functions/recursion/fibonacci.py b/functions/recursion/fibonacci.py index 0bf2b15..620e648 100644 --- a/functions/recursion/fibonacci.py +++ b/functions/recursion/fibonacci.py @@ -1,16 +1,16 @@ # program to find out nth fibonacci number using recursion # made by : rakesh kumar -# last compiled : 20-12-2018 +# last compiled : 20-12-2018 def fibonacci(n): - if(n==1): + if(n == 1): return 0 - elif(n==2): + elif(n == 2): return 1 else: return fibonacci(n-1)+fibonacci(n-2) -if __name__ == "__main__": - for x in range(1,21): - print(fibonacci(x),end=" ") + +result = fibonacci(30) +print(result) diff --git a/functions/recursion/natutal_no.py b/functions/recursion/natutal_no.py index c5d8ff2..54a36f7 100644 --- a/functions/recursion/natutal_no.py +++ b/functions/recursion/natutal_no.py @@ -1,3 +1,7 @@ +# recursive function to print first 100 natural number +# made by : rakesh kumar + + def natural(n): if n == 100: print(100, end=" ") @@ -8,4 +12,4 @@ def natural(n): # function call to print 100 natural no -natural(1) +natural(10) # diff --git a/functions/recursion/power.py b/functions/recursion/power.py index e69de29..88e10f8 100644 --- a/functions/recursion/power.py +++ b/functions/recursion/power.py @@ -0,0 +1,16 @@ +<<<<<<< HEAD + +def xpower(x, y): + if y == 1: + return x + else: + return (x*xpower(x, y-1)) + + +x = int(input("Enter x : ")) +y = int(input("Enter y : ")) +result = xpower(x, y) + +print("\n\n {} power {} is {} ".format(x, y, result)) +======= +>>>>>>> 62b05352fd92e1d91afddb64866852dd99f18c9a diff --git a/functions/recursion/recursive_linear_search.py b/functions/recursion/recursive_linear_search.py new file mode 100644 index 0000000..6895d46 --- /dev/null +++ b/functions/recursion/recursive_linear_search.py @@ -0,0 +1,18 @@ +def Linear_Search(l, start, n, value): + if start < n: + if l[start] == value: + return 1 + else: + return Linear_Search(l, start+1, n, value) + else: + return 0 + + +l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +data = int(input('Enter number to search :')) +n = len(l)-1 +result = Linear_Search(l, 0, n, data) +if(result == 1): + print('data found') +else: + print('Data not not found') diff --git a/functions/recursion/sum_digit.py b/functions/recursion/sum_digit.py index 50ae394..51371e6 100644 --- a/functions/recursion/sum_digit.py +++ b/functions/recursion/sum_digit.py @@ -1,9 +1,14 @@ -def sum(n): - if n ==0: +# recursive function to find out sum of digits +# made by : rakesh kumar + + +def summ(n): + if n == 0: return 0 else: - return(n%10+sum(n//10)) + return(n % 10+summ(n//10)) # 5 + 2 + 1+0 + n = int(input("Enter x : ")) -result = sum(n) -print("Sum of digits : ",result) \ No newline at end of file +result = summ(n) +print("Sum of digits : ", result) diff --git a/functions/recursion/tempCodeRunnerFile.py b/functions/recursion/tempCodeRunnerFile.py index 50ae394..d0f5354 100644 --- a/functions/recursion/tempCodeRunnerFile.py +++ b/functions/recursion/tempCodeRunnerFile.py @@ -1,9 +1 @@ -def sum(n): - if n ==0: - return 0 - else: - return(n%10+sum(n//10)) - -n = int(input("Enter x : ")) -result = sum(n) -print("Sum of digits : ",result) \ No newline at end of file +l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] \ No newline at end of file diff --git a/matplotlib/frequency_polygon.py b/matplotlib/frequency_polygon.py index fc831df..7ddb20b 100644 --- a/matplotlib/frequency_polygon.py +++ b/matplotlib/frequency_polygon.py @@ -1,4 +1,6 @@ import matplotlib.pyplot as plt +<<<<<<< HEAD +======= from numpy import linspace,pi,sin,cos,tan #multiple figures @@ -17,3 +19,4 @@ plt.hist(data,bins=[0,10,20,30,40,50,60],color="green") plt.scatter(frequency,x) plt.show() +>>>>>>> da25a2a32ac30d0980ed6d1d3ad58008d8ff0b21 diff --git a/matplotlib/pie_graph.py b/matplotlib/pie_graph.py index 7960dd8..812d1e4 100644 --- a/matplotlib/pie_graph.py +++ b/matplotlib/pie_graph.py @@ -3,7 +3,7 @@ import matplotlib.pyplot as plt import numpy as np -x = ['Delhi','Banglore','Chennai','Pune','Ghaziabad','Udupi'] -y = [250,300,260,400,599,320] -plt.pie(y,labels=x,autopct='%.2f',) -plt.show() \ No newline at end of file +x = ['Delhi', 'Banglore', 'Chennai', 'Pune', 'Ghaziabad', 'Udupi'] +y = [250, 300, 260, 400, 599, 320] +plt.pie(y, labels=x, autopct='%.2f',) +plt.show() diff --git a/matplotlib/simpleplt.py b/matplotlib/simpleplt.py index 5b099ff..3099d40 100644 --- a/matplotlib/simpleplt.py +++ b/matplotlib/simpleplt.py @@ -1,7 +1,12 @@ import matplotlib.pyplot as plt +<<<<<<< HEAD +plt +plt.show() +======= import numpy as np x = np.linspace(0,2.0*np.pi,101) # print(x) y = np.sin(x) plt.plot(x,y,color="red",linestyle="--",linewidth="5") -plt.show() \ No newline at end of file +plt.show() +>>>>>>> da25a2a32ac30d0980ed6d1d3ad58008d8ff0b21 diff --git a/opencv_project/manipulating_pixel.py b/opencv_project/manipulating_pixel.py index a8b20db..7c4aa69 100644 --- a/opencv_project/manipulating_pixel.py +++ b/opencv_project/manipulating_pixel.py @@ -1,4 +1,4 @@ import cv2 image =cv2.imread('walter.jpg',1) -print(image) \ No newline at end of file +print(image) \ No newline at end of file diff --git a/pdf_spilter.py b/pdf_spilter.py index 71bd875..0f9f3d7 100644 --- a/pdf_spilter.py +++ b/pdf_spilter.py @@ -1,33 +1,37 @@ -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- # Name: pdf spiller # Purpose: split pdf in to single pages # Author: acer -## Created: 13-04-2018 +# Created: 13-04-2018 # Copyright: (c) acer 2018 # Licence: -#------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------- import os -import sys # module for terminating -import glob # +import sys # module for terminating +import glob # import tkinter as tk from tkinter import filedialog from PyPDF2 import PdfFileReader, PdfFileWriter -def pdf_splitter(path,dest): + + +def pdf_splitter(path, dest): fname = os.path.splitext(os.path.basename(path))[0] pdf = PdfFileReader(path) for page in range(pdf.getNumPages()): pdf_writer = PdfFileWriter() pdf_writer.addPage(pdf.getPage(page)) - output_filename = os.path.join(dest,'{}_page_{}.pdf'.format(fname, page+1)) - #print(output_filename) + output_filename = os.path.join( + dest, '{}_page_{}.pdf'.format(fname, page+1)) + # print(output_filename) with open(output_filename, 'wb') as out: pdf_writer.write(out) print('Created: {}'.format(output_filename)) + if __name__ == '__main__': #path = "Computer_Science.pdf" root = tk.Tk() root.withdraw() - path = filedialog.askopenfilename() #source file name + path = filedialog.askopenfilename() # source file name dest = filedialog.askdirectory() # destination folder - pdf_splitter(path,dest) \ No newline at end of file + pdf_splitter(path, dest) diff --git a/webscraper/youtubeDownloader.py b/webscraper/youtubeDownloader.py index f35c99a..edabf2e 100644 --- a/webscraper/youtubeDownloader.py +++ b/webscraper/youtubeDownloader.py @@ -4,5 +4,13 @@ # import shutil ydl_opts = {} with youtube_dl.YoutubeDL(ydl_opts) as ydl: +<<<<<<< HEAD ydl.download(['https://www.youtube.com/watch?v=WfGMYdalClU']) +======= +<<<<<<< HEAD + ydl.download(['https://youtu.be/GkMnqTnjImk']) +======= + ydl.download(['https://www.youtube.com/watch?v=QaeXCar-NaM&t=2740s']) +>>>>>>> 99b44d3436e1335d5f1c119dc0467b27bfa0bd2b +>>>>>>> 62b05352fd92e1d91afddb64866852dd99f18c9a