equal
deleted
inserted
replaced
3 |
3 |
4 .. A - Students and teachers from Science and engineering backgrounds |
4 .. A - Students and teachers from Science and engineering backgrounds |
5 B - |
5 B - |
6 C - |
6 C - |
7 D - |
7 D - |
|
8 |
|
9 .. #. How to print some value |
|
10 .. #. How to print using modifiers |
|
11 .. #. How to take input from user |
|
12 .. #. How to display a prompt to the user before taking the input |
|
13 |
8 |
14 |
9 .. Prerequisites |
15 .. Prerequisites |
10 .. ------------- |
16 .. ------------- |
11 |
17 |
12 .. 1. Loops |
18 .. 1. Loops |
71 |
77 |
72 As you can see, the values of x and y are substituted in place of %2.1f and %d |
78 As you can see, the values of x and y are substituted in place of %2.1f and %d |
73 |
79 |
74 {{{ Pause here and try out the following exercises }}} |
80 {{{ Pause here and try out the following exercises }}} |
75 |
81 |
76 %% 1 %% What happens when you do print "x is %d y is %f"%(x) |
82 %% 1 %% What happens when you do ``print "x is %d y is %f" %(x, y)`` |
77 |
83 |
78 {{{ continue from paused state }}} |
84 {{{ continue from paused state }}} |
79 |
85 |
80 We see that the int value of x and float value of y are printed corresponding |
86 We see that the int value of x and float value of y are printed corresponding |
81 to the modifiers used in the print statement. |
87 to the modifiers used in the print statement. |
169 {{{ Pause here and try out the following exercises }}} |
175 {{{ Pause here and try out the following exercises }}} |
170 |
176 |
171 %% 4 %% How do you display a prompt and let the user enter input in a new line |
177 %% 4 %% How do you display a prompt and let the user enter input in a new line |
172 |
178 |
173 {{{ continue from paused state }}} |
179 {{{ continue from paused state }}} |
|
180 |
|
181 .. #[Puneeth: We didn't talk of new-line character till now, did we?] |
|
182 .. #[Puneeth: non-programmers might not know?] |
174 |
183 |
175 The trick is to include a newline character at the end of the prompt string. |
184 The trick is to include a newline character at the end of the prompt string. |
176 :: |
185 :: |
177 |
186 |
178 ip = raw_input("Please enter a number in the next line\n> ") |
187 ip = raw_input("Please enter a number in the next line\n> ") |