Page 150 - CodePilot V5.0 C8
P. 150

Program 4 A program to take user input and print it as a string.

                      Program4.py                                                       Output

                   File  Edit  Format    Run   Options   Window    Help              Enter your name: Aarti
                                                                                     Hello, Aarti
                   name = input("Enter your name: ")
                   print("Hello, ",name)




                    Program 5 A program to demonstrate strings enclosed in single and double quotes.

                      Program5.py                                                        Output

                   File  Edit  Format    Run   Options   Window    Help               A
                                                                                      Mayur
                    str1 = 'A'
                    str2= "Mayur"
                    print(str1)
                    print(str2)




                  CREATING MULTILINE STRINGS
                  A multiline string in Python begins and ends with either three single quotes or three double quotes.
                  Any quotes, tabs or newlines in between the “triple quotes” are considered part of the string.

                    Program 6 A program to create a multiline string.


                      Program6.py
                   File  Edit  Format   Run    Options   Window    Help


                   multi_line_str = """Python is a simple, high-level programming language
                   known for its readability and versatility.
                   It supports multiple paradigms,
                   including procedural, object-oriented and functional programming."""
                   print(multi_line_str)



                  The output of the preceding code is as follows:

                      Output

                   Python is a simple, high-level programming language
                   known for its readability and versatility.
                   It supports multiple paradigms,
                   including procedural, object-oriented and functional programming.





                   148
                        CodePilot (V5.0)-VIII
   145   146   147   148   149   150   151   152   153   154   155