diff options
Diffstat (limited to 'getting_started_with_strings/slides.org')
-rw-r--r-- | getting_started_with_strings/slides.org | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/getting_started_with_strings/slides.org b/getting_started_with_strings/slides.org index cd95474..e94a9b1 100644 --- a/getting_started_with_strings/slides.org +++ b/getting_started_with_strings/slides.org @@ -53,10 +53,10 @@ - Print a string repeatedly. - Access individual elements of the string. - Learn immutability of strings. -* Question 1 +* Exercise 1 Obtain the string ~%% -------------------- %%~ (20 hyphens) without typing out all the twenty hyphens. -* Question 2 +* Exercise 2 Given a string, ~s~ which is ~Hello World~ , what is the output of:: #+begin_src python s[-5] @@ -74,9 +74,11 @@ * Evaluation 1. Write code to assign s, the string ``' is called the apostrophe`` + 2. Given strings s and t, ``s = "Hello"`` and ``t = "World"`` and an integer r, ``r = 2``. What is the output of s * r + s * t? + 3. How will you change s='hello' to s='Hello'. - s[ 0 ]= H @@ -85,8 +87,10 @@ * Solutions 1. s = "` is called the apostrophe" + 2. HelloHelloWorldWorld + 3. Strings are immutable,hence cannot be manipulated. * |