17 Checklist OK? : <put date stamp here, if OK> [2010-10-05] |
17 Checklist OK? : <put date stamp here, if OK> [2010-10-05] |
18 |
18 |
19 Script |
19 Script |
20 ------ |
20 ------ |
21 |
21 |
22 Hello friends and welcome to the tutorial on Input/Output |
22 Hello friends and welcome to this tutorial on Input/Output |
23 |
23 |
24 {{{ Show the slide containing title }}} |
24 {{{ Show the slide containing title }}} |
25 |
25 |
26 {{{ Show the slide containing the outline slide }}} |
26 {{{ Show the slide containing the outline slide }}} |
27 |
27 |
36 |
36 |
37 a = "This is a string" |
37 a = "This is a string" |
38 a |
38 a |
39 print a |
39 print a |
40 |
40 |
|
41 |
41 ``print a``, obviously, is printing the value of ``a``. |
42 ``print a``, obviously, is printing the value of ``a``. |
|
43 |
42 As you can see, even when you type just a, the value of a is shown. |
44 As you can see, even when you type just a, the value of a is shown. |
43 But there is a difference. |
45 But there is a difference. |
|
46 |
|
47 .. #[Amit: The next sentence does seem to be clear enough] |
44 |
48 |
45 Typing a shows the value of a while print a prints the string. This difference |
49 Typing a shows the value of a while print a prints the string. This difference |
46 becomes more evident when we use strings with newlines in them. |
50 becomes more evident when we use strings with newlines in them. |
47 type |
51 type |
48 :: |
52 :: |
59 |
63 |
60 .. #[punch: I think we could show that?] |
64 .. #[punch: I think we could show that?] |
61 |
65 |
62 We shall look at different ways of outputting the data. |
66 We shall look at different ways of outputting the data. |
63 |
67 |
64 ``print`` statement also accepts the syntax of C's ``printf`` statement. |
68 |
65 Various arguments can be passed to ``print`` using modifiers. |
69 .. #[Amit: C's printf syntax ?? i think its better to elaborate the |
|
70 idea] |
|
71 |
|
72 print statement in python supports string formatting. |
|
73 Various arguments can be passed to print using modifiers. |
|
74 |
66 type |
75 type |
67 :: |
76 :: |
68 |
77 |
69 x = 1.5 |
78 x = 1.5 |
70 y = 2 |
79 y = 2 |
169 |
178 |
170 prints the string given as argument and then waits for the user input. |
179 prints the string given as argument and then waits for the user input. |
171 |
180 |
172 {{{ Pause here and try out the following exercises }}} |
181 {{{ Pause here and try out the following exercises }}} |
173 |
182 |
174 %% 4 %% How do you display a prompt and let the user enter input in a new line |
183 %% 4 %% How do you display a prompt and let the user enter input in next line |
175 |
184 |
176 {{{ continue from paused state }}} |
185 {{{ continue from paused state }}} |
177 |
186 |
178 .. #[Puneeth: We didn't talk of new-line character till now, did we?] |
187 .. #[Puneeth: We didn't talk of new-line character till now, did we?] |
179 .. #[Puneeth: non-programmers might not know?] |
188 .. #[Puneeth: non-programmers might not know?] |
180 |
189 |
|
190 .. #[Amit: Well there is a discussion earlier about new lines, I think its good |
|
191 .. as a slight trick question. But may be next line is a more easier lexicon] |
|
192 |
181 The trick is to include a newline character at the end of the prompt string. |
193 The trick is to include a newline character at the end of the prompt string. |
182 :: |
194 :: |
183 |
195 |
184 ip = raw_input("Please enter a number in the next line\n> ") |
196 ip = raw_input("Please enter a number in the next line\n> ") |
185 |
197 |
186 prints the newline character and hence the user enters input in the new line |
198 prints the newline character and hence the user enters input in the next line |
187 |
199 |
188 {{{ Show summary slide }}} |
200 {{{ Show summary slide }}} |
189 |
201 |
190 This brings us to the end of the tutorial. |
202 This brings us to the end of the tutorial. |
191 we have learnt |
203 In this totorial we have learnt |
192 |
204 |
193 * How to print some value |
205 * How to print some value |
194 * How to print using modifiers |
206 * How to print using modifiers |
195 * How to take input from user |
207 * How to take input from user |
196 * How to display a prompt to the user before taking the input |
208 * How to display a prompt to the user before taking the input |
197 |
209 |
198 {{{ Show the "sponsored by FOSSEE" slide }}} |
210 {{{ Show the "sponsored by FOSSEE" slide }}} |
199 |
211 |
200 #[Nishanth]: Will add this line after all of us fix on one. |
212 |
201 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India |
213 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India |
202 |
214 |
203 Hope you have enjoyed and found it useful. |
215 Hope you have enjoyed and found it useful. |
204 Thankyou |
216 Thank You. |
205 |
217 |