Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b2c41ad
Create sum of even number
sidtiwari2712 Oct 1, 2021
753e27c
sorting
S-andeep-Yadav Oct 1, 2021
5822d54
Create Merge Sort
pandey-sudip Oct 2, 2021
ee256e8
Create MergeSort.py
YAKSHUMAKKAR39 Oct 2, 2021
6086924
Merge pull request #4 from YAKSHUMAKKAR39/patch-3
Krushna-Prasad-Sahoo Oct 2, 2021
acbf5b3
Merge pull request #3 from Technical-Vandar-885/main
Krushna-Prasad-Sahoo Oct 2, 2021
fee3954
Merge pull request #2 from S-andeep-Yadav/main
Krushna-Prasad-Sahoo Oct 2, 2021
47089ce
Merge pull request #1 from sidtiwari2712/main
Krushna-Prasad-Sahoo Oct 2, 2021
4b01ebf
Merge branch 'prasun420:main' into main
Krushna-Prasad-Sahoo Oct 2, 2021
a9f78d8
Update README.md
Ahamed-Sajeeth Oct 2, 2021
d7c1543
Create add two number
sidtiwari2712 Oct 2, 2021
232b0f3
Create add two number
sidtiwari2712 Oct 2, 2021
4f64e60
Create solve quadratic
sidtiwari2712 Oct 2, 2021
1b3f7d2
Create swap in python
sidtiwari2712 Oct 2, 2021
576748b
Add files via upload
Debjani12 Oct 2, 2021
3de7b7d
Add files via upload
Debjani12 Oct 2, 2021
2c8c287
Add files via upload
Debjani12 Oct 2, 2021
573cb0d
Add files via upload
Debjani12 Oct 2, 2021
344f8dc
Add files via upload
Debjani12 Oct 2, 2021
3091594
Add files via upload
Debjani12 Oct 2, 2021
acff20c
Add files via upload
Debjani12 Oct 2, 2021
6281bdd
Add files via upload
Debjani12 Oct 2, 2021
379e7d1
Merge pull request #8 from Debjani12/main
Krushna-Prasad-Sahoo Oct 3, 2021
9f9c6e3
Merge pull request #6 from sidtiwari2712/patch-3
Krushna-Prasad-Sahoo Oct 3, 2021
9c3d5ca
Merge pull request #5 from Ahamed-Sajeeth/main
Krushna-Prasad-Sahoo Oct 3, 2021
68a969d
Merge pull request #7 from sidtiwari2712/main
Krushna-Prasad-Sahoo Oct 3, 2021
d1bc191
Merge branch 'prasun420:main' into main
Krushna-Prasad-Sahoo Oct 3, 2021
e6e0a9e
Update README.md
Ahamed-Sajeeth Oct 3, 2021
0c9da9a
Merge branch 'Krushna-Prasad-Sahoo:main' into main
Ahamed-Sajeeth Oct 3, 2021
469a07c
Merge pull request #9 from Ahamed-Sajeeth/main
Krushna-Prasad-Sahoo Oct 3, 2021
191f94c
Create Selectionsort.py
YAKSHUMAKKAR39 Oct 3, 2021
deb5d18
Merge pull request #10 from YAKSHUMAKKAR39/main
Krushna-Prasad-Sahoo Oct 4, 2021
3f19afe
Added a python to calculate Area of a Circle
ThenuSand Oct 4, 2021
67070e5
Create Sort numeric strings in a list in Python by Naive Methodby
Ashutoshranjan31011955 Oct 5, 2021
e406b21
Merge pull request #11 from ThenuSand/main
Krushna-Prasad-Sahoo Oct 6, 2021
f683028
Merge pull request #12 from Ashutoshranjan31011955/main
Krushna-Prasad-Sahoo Oct 6, 2021
b48bcba
Kadane's Algorithm
SomRawat Oct 15, 2021
43b22e1
Merge pull request #13 from SomRawat/main
Krushna-Prasad-Sahoo Oct 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Kadanes_Algorithm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def maxSubArraySum(arr,size):

max_till_now = arr[0]
max_ending = 0

for i in range(0, size):
max_ending = max_ending + arr[i]
if max_ending < 0:
max_ending = 0


elif (max_till_now < max_ending):
max_till_now = max_ending

return max_till_now

arr = [-2, -3, 4, -1, -2, 5, -3]
print("Maximum Sub Array Sum Is" , maxSubArraySum(arr,len(arr)))
80 changes: 80 additions & 0 deletions Merge Sort
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Python program for implementation of MergeSort

# Merges two subarrays of arr[].
# First subarray is arr[l..m]
# Second subarray is arr[m+1..r]


def merge(arr, l, m, r):
n1 = m - l + 1
n2 = r - m

# create temp arrays
L = [0] * (n1)
R = [0] * (n2)

# Copy data to temp arrays L[] and R[]
for i in range(0, n1):
L[i] = arr[l + i]

for j in range(0, n2):
R[j] = arr[m + 1 + j]

# Merge the temp arrays back into arr[l..r]
i = 0 # Initial index of first subarray
j = 0 # Initial index of second subarray
k = l # Initial index of merged subarray

while i < n1 and j < n2:
if L[i] <= R[j]:
arr[k] = L[i]
i += 1
else:
arr[k] = R[j]
j += 1
k += 1

# Copy the remaining elements of L[], if there
# are any
while i < n1:
arr[k] = L[i]
i += 1
k += 1

# Copy the remaining elements of R[], if there
# are any
while j < n2:
arr[k] = R[j]
j += 1
k += 1

# l is for left index and r is right index of the
# sub-array of arr to be sorted


def mergeSort(arr, l, r):
if l < r:

# Same as (l+r)//2, but avoids overflow for
# large l and h
m = l+(r-l)//2

# Sort first and second halves
mergeSort(arr, l, m)
mergeSort(arr, m+1, r)
merge(arr, l, m, r)


# Driver code to test above
arr = [12, 11, 13, 5, 6, 7]
n = len(arr)
print("Given array is")
for i in range(n):
print("%d" % arr[i]),

mergeSort(arr, 0, n-1)
print("\n\nSorted array is")
for i in range(n):
print("%d" % arr[i]),

# This code is contributed by Mohit Kumra
71 changes: 71 additions & 0 deletions MergeSort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
def merge(arr, l, m, r):
n1 = m - l + 1
n2 = r - m

# create temp arrays
L = [0] * (n1)
R = [0] * (n2)

# Copy data to temp arrays L[] and R[]
for i in range(0, n1):
L[i] = arr[l + i]

for j in range(0, n2):
R[j] = arr[m + 1 + j]

# Merge the temp arrays back into arr[l..r]
i = 0 # Initial index of first subarray
j = 0 # Initial index of second subarray
k = l # Initial index of merged subarray

while i < n1 and j < n2:
if L[i] <= R[j]:
arr[k] = L[i]
i += 1
else:
arr[k] = R[j]
j += 1
k += 1

# Copy the remaining elements of L[], if there
# are any
while i < n1:
arr[k] = L[i]
i += 1
k += 1

# Copy the remaining elements of R[], if there
# are any
while j < n2:
arr[k] = R[j]
j += 1
k += 1

# l is for left index and r is right index of the
# sub-array of arr to be sorted


def mergeSort(arr, l, r):
if l < r:

# Same as (l+r)//2, but avoids overflow for
# large l and h
m = l+(r-l)//2

# Sort first and second halves
mergeSort(arr, l, m)
mergeSort(arr, m+1, r)
merge(arr, l, m, r)


# Driver code to test above
arr = [12, 11, 13, 5, 6, 7]
n = len(arr)
print("Given array is")
for i in range(n):
print("%d" % arr[i]),

mergeSort(arr, 0, n-1)
print("\n\nSorted array is")
for i in range(n):
print("%d" % arr[i])
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
### This repo contains sorting program in Python.
#### List of programs available here :
- Bubble Sort
- Bubble Sort:is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
- Insertion Sort
- Heap Sort
- Maximum of two numbers in Python
- Python Program for simple interest
- Python Program for factorial of a number
- Django and Flask are most Popular Python Framework
- Python use for ML Studies Also
- python widely use programming Language

21 changes: 21 additions & 0 deletions Selectionsort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
A = [64, 25, 12, 22, 11]

# Traverse through all array elements
for i in range(len(A)):

# Find the minimum element in remaining
# unsorted array
min_idx = i
for j in range(i+1, len(A)):
if A[min_idx] > A[j]:
min_idx = j

# Swap the found minimum element with
# the first element
A[i], A[min_idx] = A[min_idx], A[i]

# Driver code to test above
print ("Sorted array")
for i in range(len(A)):
print("%d" %A[i]),
6 changes: 6 additions & 0 deletions Sort numeric strings in a list in Python by Naive Methodby
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Naive Method
numeric string sorting
for i in range(0, len(test_list)) :
test_list[i] = int(test_list[i])
test_list.sort()
print ("The resultant sorted list : " + str(test_list))
10 changes: 10 additions & 0 deletions add two number
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This program adds two numbers

num1 = 1.5
num2 = 6.3

# Add two numbers
sum = num1 + num2

# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
10 changes: 10 additions & 0 deletions area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#program to find area of circle using functions
import math

#Function that calculates area of circle
def area_of_circle(r):
a = r**2 * math.pi
return a

r = float(input("Enter the radius of the circle: "))
print("%.2f" %area_of_circle(r))
60 changes: 60 additions & 0 deletions bullcowgame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import random as rand
import emoji as emo

emo_cow = emo.emojize(emo.demojize('🐄'))
emo_bull = emo.emojize(emo.demojize('🐂'))
print('\n\033[1m' + ' --: Welcome to Cows (', emo_cow, ') and Bulls (', emo_bull, ') game :--' + '\033[0m')

rand_num = rand.randrange(1000, 9999, 1)
rand_num_list = list(str(rand_num).replace("", ""))

trial = 0
error_dig = 0
error_let = 0

while True:
user_num = input('Guess the 4 digit number : ')
user_num_list = list(str(user_num).replace("", ""))

def if_contain_letter(x):
for ele in x:
if ele.isalpha():
con = True
else:
con = False
return con

if len(user_num_list) != 4:
print(' DIGIT no. Error : \n Your entered number does not contain 4 digits')
error_dig += 1
if error_dig > 3:
print('*) WARNING !! What are you doing ? Too much errors ! Be careful !')

if if_contain_letter(user_num_list):
print('DIGIT type Error :\n inputted number contains letter ')
error_let += 1

if not if_contain_letter(user_num_list):
if len(user_num_list) == 4:
a = []
b = []

for i in range(len(user_num_list)):
if rand_num_list[i] == user_num_list[i]:
a.append(user_num_list[i])

if rand_num_list[i] != user_num_list[i]:
if user_num_list[i] in rand_num_list:
b.append(user_num_list[i])

num_of_cow = len(a)
num_of_bull = len(b)
print(num_of_cow, ' cow (', emo_cow, ')')
print(num_of_bull, ' bull (', emo_bull, ')')
trial += 1

if str(user_num) == str(rand_num):
print('\n\033[1m' + '### Congratulations! , Well played ###' + '\033[0m')
print('Trials = ', trial)
print('Errors = ', error_dig + error_let)
break
29 changes: 29 additions & 0 deletions c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def isVowel(c):
return (c == 'A' or c == 'E' or c == 'I' or
c == 'O' or c == 'U' or c == 'a' or
c == 'e' or c == 'i' or c == 'o' or
c == 'u');


def pigLatin(s):


length = len(s);
index = -1;
for i in range(length):
if (isVowel(s[i])):
index = i;
break;


if (index == -1):
return "-1";


return s[index:] + s[0:index] + "ay";

str = pigLatin("graphic");
if (str == "-1"):
print("No vowels found. Pig Latin not possible");
else:
print(str);
32 changes: 32 additions & 0 deletions calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
opt = int(input("enter the option you want to perform : 1.addition 2.multiplication"))
if opt==1:
s=0
n=int(input("enter how many times you want to sum up :"))
print("enter",n,"numbers : ")
for i in range(0,n):
a=int(input("enter the number"))
s=s+a
print("the result is : ",s)

elif opt==2:
m=1
n1=int(input("how many times you want to multiply : "))
print("enter",n1,"numbers :")
for i in range(0,n1):

b=int(input("enter the number :"))
m=m*b
print("the result is :",m)
elif opt==3:
n2=int(input("how many times you want to substract :"))
print("enter", n2 ,"numbers: ")
a=int(input("enter the 1st number"))
b=int(input("enter the 2nd number"))
#c=(a-b)
d=(n2-2)
print("you have to enter ", d, "numbers more")
for i in range(0,d):
c=(a-b)
e=int(input("enter the number : "))
f=c-e
print("the result is :", f)
11 changes: 11 additions & 0 deletions checkconnection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from urllib.request import urlopen ##importing necessary library this library contains all the modules for url status checking

name=input("enter your name:") ## entering the user name

def status(): ## defining the function to check the status
try:
urlopen("https://www.youtube.com/",timeout=1) ## if the url is openable then user is connected
print(name,"you are connected to internet")
except:
print(name,"you are not connected to internet") ## otherwise not connected
status() ## calling the status function
Loading