Skip to content

Commit 1fa164c

Browse files
NguyenDa18egonSchiele
authored andcommitted
Resolve Issue egonSchiele#40: Python 2 print statements changed to use Python 3 print function (egonSchiele#50)
* Update 01_selection_sort.py Updated last print statement for Python 3 print function. * Update 01_countdown.py Updated print statement to print function for Python 3. * Update 05_quicksort.py Updated print statement to print function for Python 3. * Update 01_price_of_groceries.py Condensed dictionary creation into one line, edited print statement to a print function for Python 3. * Update 01_set_covering.py Changed print statement to print function for Python 3. * Update 01_binary_search.py Changed print statements to print function for Python 3.
1 parent a010e5c commit 1fa164c

File tree

6 files changed

+8
-13
lines changed

6 files changed

+8
-13
lines changed

01_introduction_to_algorithms/python/01_binary_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def binary_search(list, item):
2222
return None
2323

2424
my_list = [1, 3, 5, 7, 9]
25-
print binary_search(my_list, 3) # => 1
25+
print(binary_search(my_list, 3)) # => 1
2626

2727
# 'None' means nil in Python. We use to indicate that the item wasn't found.
28-
print binary_search(my_list, -1) # => None
28+
print(binary_search(my_list, -1)) # => None

02_selection_sort/python/01_selection_sort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def selectionSort(arr):
1919
newArr.append(arr.pop(smallest))
2020
return newArr
2121

22-
print selectionSort([5, 3, 6, 2, 10])
22+
print(selectionSort([5, 3, 6, 2, 10]))

03_recursion/python/01_countdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def countdown(i):
2-
print i
2+
print(i)
33
# base case
44
if i <= 0:
55
return

04_quicksort/python/05_quicksort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def quicksort(array):
1111
greater = [i for i in array[1:] if i > pivot]
1212
return quicksort(less) + [pivot] + quicksort(greater)
1313

14-
print quicksort([10, 5, 2, 3])
14+
print(quicksort([10, 5, 2, 3]))
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
book = dict()
2-
# an apple costs 67 cents
3-
book["apple"] = 0.67
4-
# milk costs $1.49
5-
book["milk"] = 1.49
6-
book["avocado"] = 1.49
7-
print book
1+
book = {"apple": 0.67, "milk": 1.49, "avocado": 1.49}
2+
print(book)

08_greedy_algorithms/python/01_set_covering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
states_needed -= states_covered
2323
final_stations.add(best_station)
2424

25-
print final_stations
25+
print(final_stations)

0 commit comments

Comments
 (0)