Skip to content

Commit e31c780

Browse files
author
cclauss
committed
Modernize Python 2 code to get ready for Python 3
1 parent 4e06949 commit e31c780

File tree

17 files changed

+38
-9
lines changed

17 files changed

+38
-9
lines changed

ciphers/playfair_cipher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def decode(ciphertext, key):
8585
plaintext = ""
8686

8787
# https://en.wikipedia.org/wiki/Playfair_cipher#Description
88-
for char1, char2 in chunk(ciphertext, 2):
88+
for char1, char2 in chunker(ciphertext, 2):
8989
row1, col1 = divmod(table.index(char1), 5)
9090
row2, col2 = divmod(table.index(char2), 5)
9191

data_structures/AVL/AVL.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'''
22
A AVL tree
33
'''
4+
from __future__ import print_function
45

56

67
class Node:

data_structures/Graph/BellmanFord.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import print_function
2+
13
def printDist(dist, V):
24
print("\nVertex Distance")
35
for i in range(V):

data_structures/Graph/BreadthFirstSearch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Author: OMKAR PATHAK
2+
from __future__ import print_function
3+
24

35
class Graph():
46
def __init__(self):

data_structures/Graph/DepthFirstSearch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Author: OMKAR PATHAK
2+
from __future__ import print_function
3+
24

35
class Graph():
46
def __init__(self):

data_structures/Graph/Dijkstra.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12

23
def printDist(dist, V):
34
print("\nVertex Distance")

data_structures/Graph/FloydWarshall.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12

23
def printDist(dist, V):
34
print("\nThe shortest path matrix using Floyd Warshall algorithm\n")
@@ -7,7 +8,7 @@ def printDist(dist, V):
78
print(int(dist[i][j]),end = "\t")
89
else:
910
print("INF",end="\t")
10-
print();
11+
print()
1112

1213

1314

@@ -29,19 +30,19 @@ def FloydWarshall(graph, V):
2930

3031

3132
#MAIN
32-
V = int(input("Enter number of vertices: "));
33-
E = int(input("Enter number of edges: "));
33+
V = int(input("Enter number of vertices: "))
34+
E = int(input("Enter number of edges: "))
3435

3536
graph = [[float('inf') for i in range(V)] for j in range(V)]
3637

3738
for i in range(V):
38-
graph[i][i] = 0.0;
39+
graph[i][i] = 0.0
3940

4041
for i in range(E):
4142
print("\nEdge ",i+1)
4243
src = int(input("Enter source:"))
4344
dst = int(input("Enter destination:"))
4445
weight = float(input("Enter weight:"))
45-
graph[src][dst] = weight;
46+
graph[src][dst] = weight
4647

4748
FloydWarshall(graph, V)

data_structures/Graph/Graph_list.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import print_function
2+
3+
14
class Graph:
25
def __init__(self, vertex):
36
self.vertex = vertex

data_structures/Graph/Graph_matrix.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import print_function
2+
3+
14
class Graph:
25

36
def __init__(self, vertex):

data_structures/Graph/dijkstra_algorithm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Author: Shubham Malik
33
# References: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
44

5+
from __future__ import print_function
56
import math
67
import sys
78
# For storing the vertex set to retreive node with the lowest distance

0 commit comments

Comments
 (0)