Page 247 - COPA VOL II of II - TP -Punjabi
P. 247

ਟਾਸਕ 2: ਸਭਟ੍ਰੰਗ ਓਪ੍ੇਸ਼ਨ
            1   ਉਦਾਹਰਨ 1: ਸਤਰ ਦੀ ਰਚਨਾ (Fig 3)                     2   ਆਉਟਪੁੱਟ (Fig 4)

             Fig 3






































              Fig 4














            Example2: Accessing characters in Python String       First character of String is:
            # Python Program to Access                            W
            # characters of String                                Last character of String is:
            String1 = “WelcometoNIMI”                             I
            print(“Initial String: “)                             Example3: Reversing a String
            print(String1)                                        #Program to reverse a string

            # Printing First character                            gfg = “welcometoNIMI”
            print(“\nFirst character of String is: “)             print(gfg[::-1])
            print(String1[0])                                     Output:
            # Printing Last character                             IMINotemoclew

            print(“\nLast character of String is: “)              Example4: Formatting of Strings
            print(String1[-1])                                    Python Program for
            Output:                                               # Formatting of Strings
            Initial String:                                       # Default order
            WelcometoNIMI                                         String1 = “{} {} {}”.format(‘Welcome’, ‘to’, ‘NIMI’)
                                      IT & ITES - COPA - (NSQF ਸੋਧੇ - 2022) - ਅਿਭਆਸ 1.39.04                    233
   242   243   244   245   246   247   248   249   250   251   252