@@ -239,7 +239,7 @@ def fib(n):
239239 a, b = 0 , 1
240240
241241 while a < n:
242- print a
242+ print (a)
243243 a, b = b, a+ b
244244
245245
@@ -256,7 +256,7 @@ fib(1000)
256256
257257``` python
258258# This prints Hello World!
259- print " Hello World!"
259+ print ( " Hello World!" )
260260
261261# This is a comment; single line comment
262262
@@ -265,7 +265,7 @@ And this is a multiline comment.
265265As this could take more than one line of comments.
266266Like this.
267267"""
268- print " Hello Again."
268+ print ( " Hello Again." )
269269```
270270
271271<small >Output: </small >
@@ -281,12 +281,12 @@ Hello Again.
281281
282282``` python
283283# Printing more texts
284- print " Hello World!"
285- print " Hello Again."
286- print " We enjoy typing."
287- print " Learning python is easy."
288- print " And fun."
289- print " Printing text is way easier."
284+ print ( " Hello World!" )
285+ print ( " Hello Again." )
286+ print ( " We enjoy typing." )
287+ print ( " Learning python is easy." )
288+ print ( " And fun." )
289+ print ( " Printing text is way easier." )
290290```
291291
292292<small >Output: </small >
@@ -305,12 +305,12 @@ Printing text is way easier.
305305#### Example 3: Printing more than just texts
306306
307307``` python
308- print " One + One =" , 1 + 1
309- print " One - Two =" , 1 - 2
310- print " Two * Five =" , 1 * 5
311- print " Four / Two =" , 4 / 2
312- print " Expression (12 * 5) - (2 ^ 3) + (1 / 2) =" , ((12 * 5 ) - (2 ** 3 ) + (1 / 2 ))
313- print " Seven is less than or equal to Six is" , 7 <= 6
308+ print ( " One + One =" , 1 + 1 )
309+ print ( " One - Two =" , 1 - 2 )
310+ print ( " Two * Five =" , 1 * 5 )
311+ print ( " Four / Two =" , 4 / 2 )
312+ print ( " Expression (12 * 5) - (2 ^ 3) + (1 / 2) =" , ((12 * 5 ) - (2 ** 3 ) + (1 / 2 ) ))
313+ print ( " Seven is less than or equal to Six is" , 7 <= 6 )
314314```
315315
316316<small >Output: </small >
@@ -334,9 +334,9 @@ last_name = "Baidhya"
334334dob = " July 30, 1992"
335335home_town = " Kathmandu, Nepal"
336336
337- print " Hi! I am" , first_name, last_name, " ."
338- print " I was born on" , dob, " ."
339- print " I'm from" , home_town, " ."
337+ print ( " Hi! I am" , first_name, last_name, " ." )
338+ print ( " I was born on" , dob, " ." )
339+ print ( " I'm from" , home_town, " ." )
340340```
341341
342342<small >Output: </small >
@@ -359,9 +359,9 @@ dob_day = 30
359359dob_year = 1992
360360difficulty = " easy"
361361
362- print " Hi! I am %s %s ." % (first_name, last_name)
363- print " I was born on %s %d , %d ." % (dob_month, dob_day, dob_year)
364- print " Python is %s to learn." % difficulty
362+ print ( " Hi! I am %s %s ." % (first_name, last_name) )
363+ print ( " I was born on %s %d , %d ." % (dob_month, dob_day, dob_year) )
364+ print ( " Python is %s to learn." % difficulty)
365365```
366366
367367<small >Output: </small >
@@ -377,14 +377,14 @@ Python is easy to learn.
377377#### Example 6: User Input
378378
379379``` python
380- print " What is your name?" ,
380+ print ( " What is your name?" )
381381
382382# This would take input from the user
383383# and store it in a variable.
384384name = raw_input ()
385385
386- print " Hi! %s . \n It's nice to meet you." % (name)
387- print " Hope you're doing good."
386+ print ( " Hi! %s . \n It's nice to meet you." % (name) )
387+ print ( " Hope you're doing good." )
388388```
389389
390390<small >Output: </small >
@@ -431,10 +431,10 @@ a_floating_point = 17.60
431431a_boolean = True
432432a_string = " Foo"
433433
434- print " Integer value = %d " % an_integer
435- print " Float value = %f " % a_floating_point
436- print " Boolean value = %r " % a_boolean
437- print " String value = %s " % a_string
434+ print ( " Integer value = %d " % an_integer)
435+ print ( " Float value = %f " % a_floating_point)
436+ print ( " Boolean value = %r " % a_boolean)
437+ print ( " String value = %s " % a_string)
438438```
439439
440440<small >Output: </small >
@@ -457,9 +457,9 @@ numbers = [1, 2, 3, 4, 5, 6, 7, 8]
457457# This is called list comprehension
458458even_numbers = [x for x in numbers if x % 2 == 0 ]
459459
460- print " Numbers: %s " % numbers
461- print " Even Numbers: %s " % even_numbers
462- print " Fruits: %s , %s and %s " % (fruits[0 ], fruits[1 ], fruits[2 ])
460+ print ( " Numbers: %s " % numbers)
461+ print ( " Even Numbers: %s " % even_numbers)
462+ print ( " Fruits: %s , %s and %s " % (fruits[0 ], fruits[1 ], fruits[2 ]) )
463463```
464464
465465<small >Output: </small >
@@ -481,9 +481,9 @@ data = {
481481 " home_town" : " Kathmandu, Nepal"
482482}
483483
484- print " Hi! I am %s ." % data[" name" ]
485- print " I was born on %s ." % data[" dob" ]
486- print " I'm from %s ." % data[" home_town" ]
484+ print ( " Hi! I am %s ." % data[" name" ])
485+ print ( " I was born on %s ." % data[" dob" ])
486+ print ( " I'm from %s ." % data[" home_town" ])
487487```
488488
489489<small >Output: </small >
0 commit comments