Skip to content

Commit

Permalink
Change print statements to Python 3 function style
Browse files Browse the repository at this point in the history
  • Loading branch information
tofu-rocketry committed May 10, 2017
1 parent 66f56b3 commit 7c6e05e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ProjectEulerAnswers.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ def prob23():
tests[abuns[i] + abuns[j]] = 0
j += 1
except IndexError:
print i, j
print abuns[i] + abuns[j]
print(i, j)
print(abuns[i] + abuns[j])
raise

#print tests
Expand All @@ -893,11 +893,11 @@ def prob23():

if time_all == 1:
if version_info >= (2, 7):
print "{:7} {:8} {}".format('Problem', 'Time (s)', 'Solution')
print("{:7} {:8} {}".format('Problem', 'Time (s)', 'Solution'))
elif version_info == (2, 6): # Python 2.6 requires field names
print "{0:7} {1:8} {2}".format('Problem', 'Time (s)', 'Solution')
print("{0:7} {1:8} {2}".format('Problem', 'Time (s)', 'Solution'))
else: # Python 2.4 compatible
print "%7s %8s %s" % ('Problem', 'Time (s)', 'Solution')
print("%7s %8s %s" % ('Problem', 'Time (s)', 'Solution'))

for problem in range(1, 24):
start = time.clock()
Expand All @@ -908,11 +908,11 @@ def prob23():
elapsed = stop - start

if version_info >= (2, 7):
print "{:7} {:8.3f} {}".format(problem, elapsed, solution)
print("{:7} {:8.3f} {}".format(problem, elapsed, solution))
elif version_info == (2, 6): # Python 2.6 requires field names
print "{0:7} {1:8.3f} {2}".format(problem, elapsed, solution)
print("{0:7} {1:8.3f} {2}".format(problem, elapsed, solution))
else: # Python 2.4 compatible
print "%7i %8.3f %s" % (problem, elapsed, solution)
print("%7i %8.3f %s" % (problem, elapsed, solution))

elif time_all == 0:
start = time.clock()
Expand All @@ -925,7 +925,7 @@ def prob23():
stop = time.clock()
elapsed = stop - start

print "Problem:", prob
print "Solution:", solution
print "Time to find solution: %.3f s" % elapsed
print
print("Problem:", prob)
print("Solution:", solution)
print("Time to find solution: %.3f s" % elapsed)
print()

0 comments on commit 7c6e05e

Please sign in to comment.