getting-started-strings.rst
changeset 166 cfae14bb6809
child 167 f22530911c51
equal deleted inserted replaced
165:53df732199a1 166:cfae14bb6809
       
     1 3.3 LO: getting started with strings (2) [madhu] 
       
     2 -------------------------------------------------
       
     3 * strings 
       
     4   + single, double, triple quoted 
       
     5 * accessing elements 
       
     6 * show immutability 
       
     7 * tell that there are methods for manipulation 
       
     8 
       
     9 
       
    10 Hello friends. Welcome to this spoken tutorial on Getting started with
       
    11 strings.
       
    12 
       
    13 {{{ Show the slide containing the title }}}
       
    14 
       
    15 {{{ Show the slide containing the outline }}}
       
    16 
       
    17 In this tutorial, we will learn what do we actually mean by strings in
       
    18 python, how python supports the use of strings. We will also learn
       
    19 some of the operations that can be performed on strings.
       
    20 
       
    21 {{{ Shift to terminal and start ipython }}}
       
    22 
       
    23 To begin with let us start ipython, by typing::
       
    24 
       
    25   ipython
       
    26 
       
    27 on the terminal
       
    28 
       
    29 So what are strings? In Python anything within either single quotes
       
    30 or double quotes or triple single quotes or triple double quotes are
       
    31 strings. This is true whatsoever, even if there is only one character
       
    32 within the quotes
       
    33 
       
    34 {{{ Type in ipython the following and read them as you type }}}::
       
    35 
       
    36   'This is a string'
       
    37   "This is a string too'
       
    38   '''This is a string as well'''
       
    39   """This is also a string"""
       
    40   'p'
       
    41 
       
    42 We can assign this string to any variable::
       
    43 
       
    44   a = 'Hello, World!'
       
    45 
       
    46 Now 'a' is a string variable. String is a collection of characters. In
       
    47 addition string is an immutable collection. So all the operations that
       
    48 are applicable to any other immutable collection in Python works on
       
    49 string as well. So we can add two strings::
       
    50 
       
    51   a = 'Hello'
       
    52   b = 'World'
       
    53   c = a + ', ' + b + '!'
       
    54 
       
    55 We can add string variables as well as the strings themselves all in
       
    56 the same statement. The addition operation performs the concatenation
       
    57 of two strings.
       
    58 
       
    59 
       
    60 
       
    61 
       
    62 
       
    63 
       
    64 {{{ Show summary slide }}}
       
    65 
       
    66 This brings us to the end of another session. In this tutorial session
       
    67 we learnt
       
    68 
       
    69   *
       
    70 
       
    71 
       
    72 {{{ Show the "sponsored by FOSSEE" slide }}}
       
    73 
       
    74 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
       
    75 
       
    76 Hope you have enjoyed and found it useful.
       
    77 Thankyou
       
    78  
       
    79 .. Author              : Madhu
       
    80    Internal Reviewer 1 :         [potential reviewer: Nishanth]
       
    81    Internal Reviewer 2 :         [potential reviewer: Amit]
       
    82    External Reviewer   :
       
    83