Skip to content

Commit 07451a6

Browse files
authored
Improved Code and removed warnings (TheAlgorithms#482)
Improved Code and removed warnings
1 parent fedb3e7 commit 07451a6

File tree

14 files changed

+33
-12
lines changed

14 files changed

+33
-12
lines changed

Graphs/ArticulationPoints.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def dfs(root, at, parent, outEdgeCount):
3737

3838
for x in range(len(isArt)):
3939
if isArt[x] == True:
40-
print(x, end=" ")
40+
print(x)
4141

4242
# Adjacency list of graph
4343
l = {0:[1,2], 1:[0,2], 2:[0,1,3,5], 3:[2,4], 4:[3], 5:[2,6,8], 6:[5,7], 7:[6,8], 8:[5,7]}

Graphs/MinimumSpanningTree_Prims.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def deleteMinimum(heap, positions):
101101
return TreeEdges
102102

103103
# < --------- Prims Algorithm --------- >
104-
n = int(input("Enter number of vertices: "))
105-
e = int(input("Enter number of edges: "))
104+
n = int(raw_input("Enter number of vertices: "))
105+
e = int(raw_input("Enter number of edges: "))
106106
adjlist = defaultdict(list)
107107
for x in range(e):
108108
l = [int(x) for x in input().split()]

Maths/FibonacciSequenceRecursion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def isPositiveInteger(limit):
99
def main():
1010
limit = int(input("How many terms to include in fibonacci series: "))
1111
if isPositiveInteger(limit):
12-
print(f"The first {limit} terms of the fibonacci series are as follows:")
12+
print("The first {limit} terms of the fibonacci series are as follows:")
1313
print([recur_fibo(n) for n in range(limit)])
1414
else:
1515
print("Please enter a positive integer: ")

Neural_Network/bpnn.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
14
'''
25
36
A Framework of Back Propagation Neural Network(BP) model

Project Euler/Problem 02/sol2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ def fib(n):
99
ls = []
1010
for _ in range(T):
1111
fib(int(input().strip()))
12-
print(*ls, sep = '\n')
12+
print(ls, sep = '\n')

Project Euler/Problem 03/sol1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
44
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
55
'''
6-
from __future__ import print_function
6+
from __future__ import print_function, division
77

88
import math
99

data_structures/Graph/BreadthFirstSearch.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Author: OMKAR PATHAK
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
4+
""" Author: OMKAR PATHAK """
5+
26
from __future__ import print_function
37

48

data_structures/Graph/DepthFirstSearch.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Author: OMKAR PATHAK
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
4+
""" Author: OMKAR PATHAK """
25
from __future__ import print_function
36

47

data_structures/Graph/Graph.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
14
from __future__ import print_function
25
# Author: OMKAR PATHAK
36

data_structures/Heap/heap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python
22

3-
from __future__ import print_function
3+
from __future__ import print_function, division
44

55
try:
66
raw_input # Python 2

dynamic_programming/fastfibonacci.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
14
"""
25
This program calculates the nth Fibonacci number in O(log(n)).
36
It's possible to calculate F(1000000) in less than a second.

machine_learning/gradient_descent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Implementation of gradient descent algorithm for minimizing cost of a linear hypothesis function.
33
"""
4-
from __future__ import print_function
4+
from __future__ import print_function, division
55
import numpy
66

77
# List of input, output pairs

other/Fischer-Yates_Shuffle.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
'''
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
"""
24
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence.
35
For more details visit
46
wikipedia/Fischer-Yates-Shuffle.
5-
'''
7+
"""
68
import random
79

810
def FYshuffle(LIST):

other/sierpinski_triangle.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/python
2+
# encoding=utf8
3+
14
'''Author Anurag Kumar | [email protected] | git/anuragkumarak95
25
36
Simple example of Fractal generation using recursive function.

0 commit comments

Comments
 (0)