Skip to content

Commit 5f92bdd

Browse files
committed
update prints
1 parent 4a715c5 commit 5f92bdd

7 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎_sources/Java4Python/conditionals.rst‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ simple example in both Python and Java.
6969

7070
grade = int(input('enter a grade'))
7171
if grade < 60:
72-
print 'F'
72+
print('F')
7373
elif grade < 70:
74-
print 'D'
74+
print('D')
7575
elif grade < 80:
76-
print 'C'
76+
print('C')
7777
elif grade < 90:
78-
print 'B'
78+
print('B')
7979
else:
80-
print 'A'
80+
print('A')
8181

8282
In Java we have a couple of ways to write this
8383

@@ -176,7 +176,7 @@ integer or enumerated constant. Second it is very easy to forget to put
176176
in the ``break`` statement. If the break statement is left out then then
177177
the next alternative will be automatically executed. For example if the
178178
grade was 95 and the ``break`` was omitted from the ``case 9:``
179-
alternative then the program would print out both A and B.
179+
alternative then the program would print(out both A and B.)
180180

181181
Boolean Operators
182182
-----------------

‎_sources/Java4Python/definingclasses.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ this as follows:
588588
def main():
589589
for i in range(10):
590590
s = Student(i,"Student-"+str(i))
591-
print 'The number of students is: ', Student.numStudents
591+
print('The number of students is: ', Student.numStudents)
592592

593593
main()
594594

‎_sources/Java4Python/firstjavaprogram.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ version of hello world for Python:
1010
::
1111

1212
def main():
13-
print "Hello World!"
13+
print("Hello World!")
1414

1515
Remember that we can define this program right at the Python command
1616
line and then run it:
@@ -239,7 +239,7 @@ something like the following class definition.
239239
class Hello(object):
240240
@staticmethod
241241
def main(args):
242-
print "Hello World!"
242+
print("Hello World!")
243243

244244
Notice that we used the decorator ``@staticmethod`` to tell the Python
245245
interpreter that ``main`` is going to be a static method. The impact of
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __repr__(self):
1515
return str(self.num)+"/"+str(self.den)
1616

1717
def show(self):
18-
print self.num,"/",self.den
18+
print(self.num,"/",self.den)
1919

2020
def __add__(self,otherfraction):
2121
# convert to a fraction
@@ -63,7 +63,7 @@ def toFract(self,n):
6363
elif isinstance(n,Fraction):
6464
otherfraction = n
6565
else:
66-
print "Error: cannot add a fraction to a ", type(n)
66+
print("Error: cannot add a fraction to a ", type(n))
6767
return None
6868
return otherfraction
6969

‎_sources/Java4Python/javadatatypes.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ temperature to Celsius.
4242
def main():
4343
fahr = int(input("Enter the temperature in F: "))
4444
cel = (fahr - 32) * 5.0/9.0
45-
print "the temperature in C is: ", cel
45+
print("the temperature in C is: ", cel)
4646

4747
main()
4848

@@ -329,7 +329,7 @@ and prints a histogram.
329329

330330
idx = 0
331331
for num in count:
332-
print idx, " occured ", num, " times."
332+
print(idx, " occured ", num, " times.")
333333
idx += 1
334334

335335
Now if we run this program on a data file that looks like this:
@@ -632,7 +632,7 @@ for this job could look like this:
632632

633633
keyList = sorted(count.keys())
634634
for k in keyList:
635-
print "%-20s occurred %4d times"%(k, count[k])
635+
print("%-20s occurred %4d times" % (k, count[k]))
636636

637637
main()
638638

‎_sources/Java4Python/loopsanditeration.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ in conjunction with the range function. For example:
1414
::
1515

1616
for i in range(10):
17-
print i
17+
print(i)
1818

1919
In Java we would write this as:
2020

@@ -51,7 +51,7 @@ Python loop would be written as:
5151
::
5252

5353
for i in range(100,-1,-5):
54-
print i
54+
print(i)
5555

5656
In Java we would write this as:
5757

@@ -71,7 +71,7 @@ In Python we can iterate over a list as follows:
7171

7272
l = [1, 1, 2, 3, 5, 8, 13, 21]
7373
for fib in l:
74-
print fib
74+
print(fib)
7575

7676
In Java we can iterate over an ArrayList of integers too:
7777

‎pavement.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
master_url = None
2626
doctrees = None
2727
if master_url is None:
28-
if gethostname() in ['web608.webfaction.com', 'rsbuilder']:
29-
master_url = 'http://interactivepython.org'
28+
if gethostname() in ['runestone.academy', 'runestone-deploy', 'rsbuilder']:
29+
master_url = 'https://runestone.academy'
3030
if os.path.exists('../../custom_courses/{}'.format(project_name)):
3131
doctrees = '../../custom_courses/{}/doctrees'.format(project_name)
3232
else:

0 commit comments

Comments
 (0)