diff -r fc71d5c27ce6 -r 8a42b4203f6d input_output/script.rst --- a/input_output/script.rst Tue Nov 09 15:15:19 2010 +0530 +++ b/input_output/script.rst Tue Nov 09 15:40:53 2010 +0530 @@ -12,7 +12,7 @@ .. 1. Loops .. Author : Nishanth Amuluru - Internal Reviewer : + Internal Reviewer : Puneeth External Reviewer : Checklist OK? : [2010-10-05] @@ -26,10 +26,10 @@ {{{ Show the slide containing the outline slide }}} Input and Output are used in almost every program we use. -In this tutorial, we shall learn +In this tutorial, we shall learn how to - * Outputting data - * Taking input from the user + * Output data + * Take input from the user type :: @@ -38,7 +38,11 @@ a print a +<<<<<<< local print a, prints the value of a. +======= +``print a``, obviously, is printing the value of ``a``. +>>>>>>> other As you can see, even when you type just a, the value of a is shown. But there is a difference. @@ -59,13 +63,20 @@ Moreover when we type just a, the value a is shown only in interactive mode and does not have any effect on the program while running it as a script. +.. #[punch: I think we could show that?] + We shall look at different ways of outputting the data. +<<<<<<< local .. #[Amit: C's printf syntax ?? i think its better to elaborate the idea] print statement in python supports string formatting. Various arguments can be passed to print using modifiers. +======= +``print`` statement also accepts the syntax of C's ``printf`` statement. +Various arguments can be passed to ``print`` using modifiers. +>>>>>>> other type :: @@ -74,7 +85,8 @@ z = "zed" print "x is %2.1f y is %d z is %s"%(x,y) -As you can see, the values of x and y are substituted in place of %2.1f and %d +As you can see, the values of x and y are substituted in place of +``%2.1f`` and ``%d`` {{{ Pause here and try out the following exercises }}} @@ -82,12 +94,12 @@ {{{ continue from paused state }}} -We see that the int value of x and float value of y are printed corresponding -to the modifiers used in the print statement. +We see that the ``int`` value of x and ``float`` value of y are +printed corresponding to the modifiers used in the print statement. -We can also see that print statement prints a new line character at the end of -line, everytime it is called. This can be suppressed by using a "," at the end -print statement. +We can also see that ``print`` statement prints a new line character +at the end of the line, everytime it is called. This can be suppressed +by using a "," at the end ``print`` statement. Let us see this by typing out following code on an editor as print_example.py