Page 148 - Plus_V2.2_C8_Flipbook
P. 148

9                            Functions and String





                                                                   in Python










                      Let’s surf

                          String                                       Functions
                          List                                         Some More Programs




                   Let’s PLug-in                                                                    Computational Thinking


                     Write the output of the following program:
                     numbers = [1, 2, 3, 4, 5]
                     for num in numbers:
                         if num == 3:
                             continue
                         if num == 5:
                             break
                         print(num)
                     ____________________________________________________________________________________
                     ____________________________________________________________________________________






                         STRING


                  A sequence of characters which is enclosed or surrounded by single (‘ ’) or double (“ ”) quotes is
                  known as a string. The sequence may include a letter, number, special characters or a backslash.
                  Python treats single quotes as double quotes.


                       Creating Strings

                  Strings can be created by enclosing characters
                  inside single or double quotes. It is like assigning
                  a value to a variable.
                  Example of a string:





                  146   Premium Edition-VIII
   143   144   145   146   147   148   149   150   151   152   153