-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
129 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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): | ||
first=mid+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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def (n=20, o=30): | ||
a = n*o | ||
return a | ||
print(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
result = summ(n) | ||
print("Sum of digits : ", result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
plt.show() | ||
>>>>>>> da25a2a32ac30d0980ed6d1d3ad58008d8ff0b21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import cv2 | ||
|
||
image =cv2.imread('walter.jpg',1) | ||
print(image) | ||
print(image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: <your 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) | ||
pdf_splitter(path, dest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters