diff options
author | Amit Sethi | 2010-11-09 15:40:53 +0530 |
---|---|---|
committer | Amit Sethi | 2010-11-09 15:40:53 +0530 |
commit | 8d896c4eb9f915a7b7da9b3b15871ad51209bf1d (patch) | |
tree | e4bb7a47d35302ac601d4c36ebeae0b326c086af /input_output/script.rst | |
parent | 4065e37886895c703f0a6495fe5894e7151543b3 (diff) | |
parent | 3ccaf26be2e2321ce074ea72448fb4240a22523e (diff) | |
download | st-scripts-8d896c4eb9f915a7b7da9b3b15871ad51209bf1d.tar.gz st-scripts-8d896c4eb9f915a7b7da9b3b15871ad51209bf1d.tar.bz2 st-scripts-8d896c4eb9f915a7b7da9b3b15871ad51209bf1d.zip |
"Merging heads"
Diffstat (limited to 'input_output/script.rst')
-rw-r--r-- | input_output/script.rst | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/input_output/script.rst b/input_output/script.rst index b5f994a..b35507d 100644 --- a/input_output/script.rst +++ b/input_output/script.rst @@ -12,7 +12,7 @@ .. 1. Loops .. Author : Nishanth Amuluru - Internal Reviewer : + Internal Reviewer : Puneeth External Reviewer : Checklist OK? : <put date stamp here, if OK> [2010-10-05] @@ -26,10 +26,10 @@ Hello friends and welcome to this tutorial on Input/Output {{{ 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 @@ type 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 @@ While typing print b prints the string and hence the newline. 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 @@ type 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 @@ As you can see, the values of x and y are substituted in place of %2.1f and %d {{{ 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 |